Copy type in forms
  • If a "copy" field type is set, and the value is an empty string and "display_label" is set to false, the field key is still written into the element. Not a big issue, but it seems inconsistent, and even setting the "label" to empty doesn't correct this.

    eg

    'some_field' => array('type' => 'copy', 'tag' => 'div', 'value' => '', 'id' => 'some-field', 'row_class' => 'some-row-name', 'display_label' => FALSE, 'label' => '');


    The above will still echo out "some_field"
  • There's a method Form_builder::simple_field_value() that is used to determine the text value for fields like 'copy', 'section' and 'fieldset'. It first looks to see if there is a non empty "value" then "label" and then "name". By using name as an option it allows you to do the following:

    $fields['My copy goes here.'] = array('type' => 'copy');

    I'm curious why you would create a field like that that is empty.
  • If it is a container for perhaps an AJAX callback. An alternative would be to use a custom field type and use a function parameter like so:

    $fields['some_value'] = array('type' => 'custom', 'value' => '<div id="some_value"></div>');
  • Yes - exactly, it was for ajax injection. But your suggestion covers that. Thanks.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!