Jump to content


Add/edit form group sections

forms

  • Please log in to reply
1 reply to this topic

#1 gavin1211

gavin1211

    Member

  • Members
  • PipPip
  • 11 posts

Posted 18 April 2012 - 08:17 PM

Is there a way to group fields, adding a header or something. Some forms can be very long when listing inputs in a linear way. Grouping would improve usability?

Thanks

#2 Cèsar Martí

Cèsar Martí

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 19 April 2012 - 08:31 AM

Hi gavin1211.

This is what I made. The example is for edit, but it's more or less the same for add.

$crud->edit_fields('name', 'surname', 'details', 'email', 'phone');


"details" it's not a real field.

$crud->display_as('details', '' )


With the last line, there won't be a label in the left.

$crud->callback_edit_field('details', array($this, 'tit_details'))


We change what we are gonna see instead of the non-field "details"

function tit_details($value = null, $primary_key = null)
{
return '<h1 class="a_class_if_you_want">'.sprintf(lang('details')).'</h1>';
}


You can write directly whatever in the h1 tag or, like me, read it from the lang file.

You have to realise, where it has the label, you will see the colon [:] alone. I didn't like it, so I changed in themes/datables/views the add.php and edit.php, around the line 40 or 42.

<div class='form-display-as-box' id="<?php echo $field->field_name; ?>_display_as_box">
<?php echo $input_fields[$field->field_name]->display_as?><?php echo ($input_fields[$field->field_name]->required)? "<span class='required'>*</span> " : ""?> <?php echo ($input_fields[$field->field_name]->display_as)? ":" : ""?></div>


With the last lines you only see the colon if there's something in the label; instead, the colon won't be.

Let me know if you have any doubt.





Also tagged with one or more of these keywords: forms

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users