Created
July 5, 2012 19:10
-
-
Save jec006/3055759 to your computer and use it in GitHub Desktop.
The manager getForm function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Passthrough from Drupal form to the correct condition for building the preview form | |
* | |
* @param $form | |
* The form array used in hook_form | |
* @param $form_state | |
* The form_state array as used in hook_form | |
* | |
* @return | |
* A drupal form array created but the root condition | |
*/ | |
public function getPreviewForm() { | |
$root_condition = $this->getRootCondition(); | |
$getForm = function($form, &$form_state) { | |
return $root_condition->getElement($form, $form_state); | |
} | |
drupal_get_form('sps_condition_preview_form', $getForm); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A form callback for use by drupal_get_form(). | |
* | |
* When called like: | |
* drupal_get_form('sps_condition_preview_form', array($this, 'getPreviewForm')) | |
* by the manager or a condition, it will return that form. | |
* | |
* @return | |
* A FAPI array for drupal_get_form if a callback is provided, or NULL | |
* | |
* @see Manager::getPreviewForm(); | |
*/ | |
function sps_condition_preview_form($form, &$form_state) { | |
if (!empty($form_state['build_info']['args'][0])) { | |
$form_function = $form_state['build_info']['args'][0]; | |
if(is_callable($form_function)) { | |
$form_function($form, $form_state); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment