Copy type in forms

edited January 2017 in Feature Requests
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"

Comments

  • edited 4:35AM
    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.
  • edited 4:35AM
    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>');
  • edited 4:35AM
    Yes - exactly, it was for ajax injection. But your suggestion covers that. Thanks.
Sign In or Register to comment.