Created
October 11, 2011 11:29
-
-
Save netmeansnet/1277864 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| /** | |
| * blog module configuration. | |
| * | |
| * @package netmeansnet | |
| * @subpackage blog | |
| * @author netmeansnet | |
| */ | |
| class blogGeneratorConfiguration extends BaseBlogGeneratorConfiguration | |
| { | |
| public function getFormFields(sfForm $form, $context) | |
| { | |
| $fields = parent::getFormFields($form, $context); | |
| if(!isset($fields['NONE'])) | |
| { | |
| foreach ($form->getWidgetSchema()->getPositions() as $name) | |
| { | |
| //if the field is already present in a fieldset we exclude | |
| $exclude = false; | |
| foreach ($fields as $fieldset) | |
| { | |
| foreach ($fieldset as $field) | |
| { | |
| if($name == $field->getName()) | |
| { | |
| $exclude = true; | |
| } | |
| } | |
| } | |
| //if the field is not excluded | |
| //and is and istance of sfFormFieldSchema we add to NONE | |
| if(!$exclude) | |
| { | |
| $fields['NONE'][$name] = new sfModelGeneratorConfigurationField($name, | |
| array_merge( | |
| array('type' => 'Text'), | |
| isset($config['default'][$name]) ? $config['default'][$name] : array(), | |
| isset($config['form'][$name]) ? $config['form'][$name] : array(), | |
| isset($config[$context][$name]) ? $config[$context][$name] : array(), | |
| array('is_real' => false) | |
| )); | |
| if(!$form[$name] instanceOf sfFormFieldSchema) | |
| { | |
| unset($fields['NONE'][$name]); | |
| } | |
| } | |
| } | |
| } | |
| foreach ($fields['NONE'] as $widget => $field) | |
| { | |
| if ($form[$widget] instanceOf sfFormFieldSchema) | |
| { | |
| unset($fields['NONE'][$widget]); | |
| $fields[$widget] = array($widget => $field); | |
| } | |
| } | |
| if(count($fields['NONE']) < 1) | |
| { | |
| unset($fields['NONE']); | |
| } | |
| return $fields; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment