function flexiform in Flexiform 7
Build a flexiform.
_state
Parameters
array $form:
Flexiform $flexiform:
Entity|stdClass $base_entity:
bool $include_actions: Boolean flag for whether the actions element should be included at the bottom of the form.
Return value
Constructed form array.
79 string references to 'flexiform'
- Flexiform::__construct in ./
flexiform.entity.inc - FlexiformBuilder::form in includes/
flexiform.builder.inc - Build the form for this flexiform.
- FlexiformBuilderFlexiform::form in includes/
builder/ flexiform.builder.inc - Build the form for this flexiform.
- FlexiformController::loadWithDisplay in ./
flexiform.entity.inc - Get flexiforms with a given display(s)
- FlexiformDisplayBase::build in includes/
flexiform.display.inc - Build the form ready for rendering.
File
- includes/
flexiform.flexiform.inc, line 135 - flexiform.flexiform.inc Helper function for embedding the fields into the flexiform in an arbitrary order
Code
function flexiform($form, &$form_state, $flexiform, $base_entity) {
// @TODO: Consider moving all of these functions into .module easier accessibility.
form_load_include($form_state, 'inc', 'flexiform', 'includes/flexiform.flexiform');
$form['#flexiform_builder'] = $builder = $flexiform
->getBuilder($base_entity);
$form = $builder
->form($form, $form_state);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'form-actions',
),
),
'#weight' => 400,
);
// We add the form's #submit array to this button along with the actual submit
// handler to preserve any submit handlers added by a form callback_wrapper.
$submit = array();
if (!empty($form['#submit'])) {
$submit += $form['#submit'];
}
// Get button settings.
$submit_text = t('Save');
if (!empty($flexiform->settings['buttons']['submit_text'])) {
$submit_text = $flexiform->settings['buttons']['submit_text'];
}
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $submit_text,
'#submit' => $submit + array(
'flexiform_submit',
),
);
if (!empty($flexiform->settings['ajax']['submit'])) {
$wrapper_id = $form_state['build_info']['form_id'] . '-ajax-wrapper';
$form['#prefix'] = '<div id="' . $wrapper_id . '">';
$form['#suffix'] = '</div>';
$form['actions']['submit']['#ajax'] = array(
'wrapper' => $wrapper_id,
'callback' => 'flexiform_submit_ajax',
);
}
// We append the validate handler to #validate in case a form callback_wrapper
// is used to add validate handlers earlier.
$form['#validate'][] = 'flexiform_validate';
if (module_exists('honeypot')) {
if (!empty($flexiform->settings['honeypot'])) {
$protections = array_keys(array_filter($flexiform->settings['honeypot']));
honeypot_add_form_protection($form, $form_state, $protections);
}
}
return $form;
}