コード例 #1
0
 public function configure()
 {
     $widgets = array();
     $validators = array();
     if ($this->getOption('is_use_id')) {
         $widgets += array('id' => new sfWidgetFormInputText());
         $validators += array('id' => new sfValidatorPass());
     }
     $widgets += array('name' => new sfWidgetFormInputText());
     $validators += array('name' => new opValidatorSearchQueryString(array('required' => false)));
     $culture = sfContext::getInstance()->getUser()->getCulture();
     foreach ($this->getProfiles() as $profile) {
         $profileI18n = $profile->Translation[$culture]->toArray();
         if ($profile->isPreset()) {
             $config = $profile->getPresetConfig();
             $profileI18n['caption'] = sfContext::getInstance()->getI18n()->__($config['Caption']);
         }
         $profileWithI18n = $profile->toArray() + $profileI18n;
         $widget = opFormItemGenerator::generateSearchWidget($profileWithI18n, array('' => '') + $profile->getOptionsArray());
         if ($widget) {
             $widgets[self::$profileFieldPrefix . $profile->getName()] = $widget;
             $validators[self::$profileFieldPrefix . $profile->getName()] = new sfValidatorPass();
         }
     }
     $this->setWidgets($widgets);
     $this->setValidators($validators);
     $this->widgetSchema->setLabel('name', '%nickname%');
     $this->widgetSchema->setNameFormat('member[%s]');
 }
コード例 #2
0
 public function configure()
 {
     $widgets = array();
     $validators = array();
     //    if ($this->getOption('is_use_id'))
     //    {
     $widgets += array('id' => new sfWidgetFormInputText());
     $validators += array('id' => new sfValidatorPass());
     //    }
     foreach ($this->getProfiles() as $profile) {
         if (ProfileTable::PUBLIC_FLAG_PRIVATE == $profile->default_public_flag && !$profile->is_edit_public_flag) {
             continue;
         }
         $profileI18n = $profile->Translation[$culture]->toArray();
         if ($profile->isPreset()) {
             $config = $profile->getPresetConfig();
             $profileI18n['caption'] = sfContext::getInstance()->getI18n()->__($config['Caption']);
         }
         $profileWithI18n = $profile->toArray() + $profileI18n;
         $widget = opFormItemGenerator::generateSearchWidget($profileWithI18n, array('' => '') + $profile->getOptionsArray());
         if ($widget) {
             $widgets[self::$profileFieldPrefix . $profile->getName()] = $widget;
             $validators[self::$profileFieldPrefix . $profile->getName()] = new sfValidatorPass();
         }
     }
     $this->setWidgets($widgets);
     $this->setValidators($validators);
     //    $this->widgetSchema->setLabel('name', '%nickname%');
     // $this->widgetSchema->setNameFormat('member[%s]');
 }