Code to render single element in Custom Form

Status
Not open for further replies.

longlam

Member
Hi All, I need to hard code the layout of a form and was wondering:
- what the code is to render a single element is?
- which php file it goes in?

In the previous versions of Fabrik I used to do the following:
- Edit the default_group.php file
- <?php $this->element = $this->elements['store']; echo $this->element->element; $this->element->rendered = true; ?>

This doesn't seem to work in the new bootstrap version of the template....
 
That's the right file, but you probably can't just echo the element any more, as there's a lot of additional classes and wrapping has to happen.

Probable best to replace ...

Code:
foreach ($this->elements as $element) :
    $this->element = $element;

   ... blah blah blah
endforeach;

... with ...

Code:
$this->element = $this->elements['store'];

Although note that if you have anything like checkboxes on your form, not rendering them will cause their values to be lost when you submit the form.

If I'm remembering correctly, add that rendered=true came from a customized template example I created many years ago, which then went through the elements array and for any that hadn't been rendered, added them to the hidden fields list, to make sure their values got submitted. But it doesn't do anything in these templates, unless you are handling that elsewhere.


-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top