Init input filed value with a data in datapath

ladyj 14 May, 2018
Hi,

I wrote a plugin which load datapath with data I need to use to init input fields in Chronoforms 5.
It works if I use custom code and I insert HTML code like this:

....
</div>
</div>
<div class="form-group gcore-form-row" id="form-row-azienda">
  <label for="azienda" class="control-label gcore-label-left">Azienda</label>
  <div class="gcore-input gcore-display-table" id="fin-azienda">
    <input name="field_name" id="field_name" value="<?php echo (isset($form->data['profile']) ? $form->data['profile']['field_name']:'');?>" placeholder="" maxlength="150" size="50" class="validate[&#039;required&#039;] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" />
  </div>
</div>
.....

The drawback is that my customer still wants to user designer function. Is there the possibility to init chronoforms 5 fileds with data in datapath and continue using form designer?

Thanks in advance
GreyHead 14 May, 2018
Hi ladyj,

Use a Custom Code action before the HTML (Render form) action and you can set a form value there:
<?php
$form->data['field_name'] = '';
if ( isset($form->data['profile']) ) {
$form->data['field_name'] = $form->data['profile']['field_name'];
}
?>
Bob
This topic is locked and no more replies can be posted.