static function create($name, $label = null, $allowMultiple = null, $maxAllowed = null, $formFields = null)
 {
     $tif = new SFTemplateInForm();
     $tif->mTemplateName = str_replace('_', ' ', $name);
     $tif->mFields = array();
     if (is_null($formFields)) {
         $fields = $tif->getAllFields();
         $field_num = 0;
         foreach ($fields as $field) {
             $tif->mFields[] = SFFormField::create($field_num++, $field);
         }
     } else {
         $tif->mFields = $formFields;
     }
     $tif->mLabel = $label;
     $tif->mAllowMultiple = $allowMultiple;
     $tif->mMaxAllowed = $maxAllowed;
     return $tif;
 }
Beispiel #2
0
 public static function getFormFieldInfo($psTemplate, $template_fields)
 {
     $form_fields = array();
     $fieldsInfo = $psTemplate->getFields();
     foreach ($fieldsInfo as $i => $psField) {
         $fieldFormArray = $psField->getObject('semanticforms_FormInput');
         if (!is_null($fieldFormArray)) {
             $formField = SFFormField::create($i, $template_fields[$i]);
             foreach ($fieldFormArray as $var => $val) {
                 if ($var == 'InputType') {
                     $formField->setInputType($val);
                 } elseif ($var == 'mandatory') {
                     $formField->setIsMandatory(true);
                 } elseif ($var == 'hidden') {
                     $formField->setIsHidden(true);
                 } elseif ($var == 'restricted') {
                     $formField->setIsRestricted(true);
                 } else {
                     $formField->setFieldArg($var, $val);
                 }
             }
             $form_fields[] = $formField;
         }
     }
     return $form_fields;
 }