Customize the history registration form template

More
12 years 2 weeks ago - 12 years 2 weeks ago #40569 by Lee
I need to customize the registration history form template beyond what the adminstration can already do and need to request only specific custom fields on this page, I know I can use the the custom field in admin options but I need more... choices

the page: [Edit Registrant]
?option=com_eventbooking&task=edit_registrant&cid[]=9&from=history

the template file:
com_eventbooking/views/registrant/tmpl/default.php

the core function currently being used to dynamically get 'ALL the custom-field records' in edit mode from the eb admin options:
Code:
<?php if (isset($this->jcFields)) { if ($this->jcFields->getTotal()) { echo $this->jcFields->renderCustomFieldsEdit($this->item->id); } } ?>
the code above pulls 'all the records', I only want to pull selected custom fields. ie. field ID 8 and 13
in addition to the standard Billing Fields I have added about 15 custom fields for the signup page, but I want it to only display maybe two of these custom fields once the user is logged in.

For example I have 2 new custom fields:

(custom form field id 8) Bus Transportation Required?: Yes / No
(custom form field id 13) How Many People require seat on Bus: QTY box

I have coded these above out (hidden) from my main registration sign-up page so they don't appear when someone initially registers as I would like the customer to comeback to site / login and then fill out additional forms fields.

What PHP function / my SQL call would I use to pull specifc fields bases on the field ID only for the end-user to edit in history?

Example (not working)
Code:
// Get custom Field # 8 only - Bus Transportation <?php if (isset($this->jcFields)) { if ($this->jcFields->getTotal()) { echo $this->jcFields->renderCustomFieldsEditMYCHOICE($this->item->id, 8); // Get custom Field # 8 only - Bus Transportation } } ?> // Get custom Field # 8 only - Bus Transportation <?php if (isset($this->jcFields)) { if ($this->jcFields->getTotal()) { echo $this->jcFields->renderCustomFieldsEditMYCHOICE($this->item->id, 13); // Get custom Field # 13 only - Bus Seat QTY } } ?>
this code below is an example of what I am using on the sign-up page to allow me to pull custom field #5 (Dinner Preferences) so I can place is where I need it (hardcoded):
Code:
<?php // BOF Custom DB # for Dinner Preferences (5) if ($this->customField) { $fields = $this->fieldsList; $fieldsOutput = $this->fieldsOutput; foreach ($fields as $field) { // BEG: Custom DB # for Dinner Preferences (5) if ($field->id == '5') { // END: Lee if ($field->depend_on_field_id) { $masterFieldValues = (array)$this->fieldAssoc[$field->depend_on_field_id]->field_values; $dependOnOptions = explode(',', $field->depend_on_options); if (count(array_intersect($masterFieldValues, $dependOnOptions))) { $displayStyle = ''; } else { $displayStyle = 'style="display:none"'; } } else { $displayStyle = ''; } switch ($field->field_type) { case FIELD_TYPE_HEADING : ?> <div class="control-group" id="field_<?php echo $field->name; ?>" <?php echo $displayStyle; ?>> <label class="control-label"><?php echo JText::_($field->title) ; ?></label> </div> <?php break ; case FIELD_TYPE_MESSAGE : ?> <div class="control-group" id="field_<?php echo $field->name; ?>" <?php echo $displayStyle; ?>> <?php echo $field->description ; ?> </div> <?php break ; default: ?> <div class="control-group" id="field_<?php echo $field->name; ?>" <?php echo $displayStyle; ?>> <label class="control-label" for="<?php echo $field->name ; ?>"> <?php echo JText::_($field->title); ?> <?php if ($field->required) { echo '<span class="required">*</span>' ; } if (strlen(trim($field->description))) { ?> <p class="field_description"><?php echo $field->description ; ?></p> <?php } ?> </label> <div class="controls"> <?php echo $fieldsOutput[$field->name]; ?> </div> </div> <?php } } // Lee } } ?>
Last edit: 12 years 2 weeks ago by Lee.

Please Log in or Create an account to join the conversation.

More
12 years 2 weeks ago #40576 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Customize the history registration form template
It is not easy to edit the code to only display the fields you want unless you know PHP programming very well. The instructions are below :

1. Open the file components/com_eventbooking/helper/fields.php

2. Find the function renderCustomFieldsEdit

3. Find the code below inside the for lop :

$row = $this->_fields[$i];

4. Change it to :

$row = $this->_fields[$i];

if (!$row->id == 5 OR row->id == 8)
{
continue;
}

By doing the above code, the system will only render edit form for custom field with id = 5 or ID = 8, not for other fields

But please be carefully with the changes you made as It might causes unexpected behavior. At the moment, there is no code for rendering a custom field directly by giving it now.


You must read and understand the code before making any changes.

Tuan
The following user(s) said Thank You: Lee

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc