protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addRequiredOption("url");
     $this->addOption("new_label", "New");
     $this->addOption("ws_url", "@pm_widget_form_doctrine_choice_or_create");
 }
 /**
  * Renders the widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N'));
     $default_text = $this->getOption('default_text', null);
     if ($default_text) {
         $default_text = __($default_text);
     } else {
         $default_text = $this->getOption('multiple') ? __("Select Some Options") . '...' : __("Select an Option") . '...';
     }
     $align_right = $this->getOption('align_right', null);
     if ($align_right) {
         if (!isset($attributes['class'])) {
             $attributes['class'] = '';
         }
         $attributes['class'] .= ' chzn-select chzn-rtl';
     }
     if (!isset($attributes['style'])) {
         $attributes['style'] = 'min-width: 300px; max-width: 700px;';
     } else {
         $attributes['style'] = '; min-width: 300px; max-width: 700px;';
     }
     $html = parent::render($name, $value, $attributes, $errors);
     $html .= dcWidgetFormChosenChoice::getWidgetInitializationJS($this->generateId($name), $value, $default_text, $this->getOption('config'));
     return $html;
 }
    /**
     * Configures the current widget.
     *
     * Available options:
     *
     *  * url:            The URL to call to get the choices to use (required)
     *  * config:         A JavaScript array that configures the JQuery autocompleter widget
     *  * value_callback: A callback that converts the value before it is displayed
     *
     * @param array $options     An array of options
     * @param array $attributes  An array of default HTML attributes
     *
     * @see sfWidgetForm
     */
    protected function configure($options = array(), $attributes = array())
    {
        $this->addOption('json_url', '/sfDoctrineFBAutocompleteJson/list/model/%model%');
        $this->addOption('cache', false);
        $this->addOption('height', false);
        $this->addOption('newel', false);
        $this->addOption('firstselected', false);
        $this->addOption('filter_case', false);
        $this->addOption('filter_hide', false);
        $this->addOption('filter_selected', false);
        $this->addOption('complete_text', false);
        $this->addOption('maxshownitems', false);
        $this->addOption('maxitems', false);
        $this->addOption('onselect', false);
        $this->addOption('onremove', false);
        $this->addOption('delay ', false);
        $this->addOption('template', <<<EOF
    %associated%
    <script type="text/javascript">
      jQuery(document).ready(function() {
        jQuery("#%id% option").attr('selected','selected');
        jQuery("#%id%").fcbkcomplete({%config%});
      });
    </script>
EOF
);
        parent::configure($options, $attributes);
    }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (false !== ($empty = $this->getOption('add_empty'))) {
         $label = true === $empty ? '' : $empty;
         $first_option = '<option value="">' . $label . '</option>';
     } else {
         $first_option = '';
     }
     return parent::render($name, $value, $attributes, $errors) . sprintf("\n<script type='text/javascript'>\n\$(function(){\n  \$('#%s').change(function(){\n    \$.getJSON('%s', { id: \$(this).val() }, function(data){\n      var options = '%s';\n      for (key in data) {\n        options += '<option value=\"' + key + '\">' + data[key] + '</option>';\n      }\n      \$('#%s').html(options);\n    })\n  })\n})\n</script>\n", $this->generateId($this->getOption('parent')), $this->getOption('url'), $first_option, $this->generateId($name));
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $select_parent = parent::render($name, $value, $attributes, $errors);
     $foreing_id = $this->getOption('foreing_id') ? $this->getOption('foreing_id') : strtolower($this->getOption('model') . '_id');
     $option_name = $this->getOption('option_name') ? $this->getOption('option_name') : 'name';
     $where = $this->getOption('where') ? ' where="' . $this->getOption('where') . '"' : '';
     $conten_tag = '<div class="moo_widget dependent_observer_select" observer_id="' . $this->getOption('observer_select_id') . '" model="' . $this->getOption('model') . '" option_name="' . $option_name . '" foreing_id="' . $foreing_id . '" action_to_select="' . url_for('mooForm/loadSelectDependent') . '"' . $where . '>';
     $conten_tag .= $select_parent;
     $conten_tag .= '</div>';
     return $conten_tag;
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:        The model class (required)
  *  * add_empty:    Whether to add a first empty value or not (false by default)
  *                  If the option is not a Boolean, the value will be used as the text value
  *  * method:       The method to use to display object values (__toString by default)
  *  * key_method:   The method to use to display the object keys (getPrimaryKey by default)
  *  * order_by:     An array composed of two fields:
  *                    * The column to order by the results (must be in the PhpName format)
  *                    * asc or desc
  *  * query:        A query to use when retrieving objects
  *  * multiple:     true if the select tag must allow multiple selections
  *  * table_method: A method to return either a query, collection or single object
  *                * Array (method=>string, parameters=>array()) - when method needs parameters
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('model');
     $this->addOption('add_empty', false);
     $this->addOption('method', '__toString');
     $this->addOption('key_method', 'getPrimaryKey');
     $this->addOption('order_by', null);
     $this->addOption('query', null);
     $this->addOption('multiple', false);
     $this->addOption('table_method', null);
     parent::configure($options, $attributes);
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $dropdown = parent::render($name, null, array('class' => 'tag-select'), $errors);
     $hidden = new sfWidgetFormInputHidden();
     $content = '';
     $values = $this->getChoices();
     if ($value) {
         foreach ($value as $i => $id) {
             if (isset($values[$id])) {
                 $content .= $this->renderContentTag('li', $values[$id] . $hidden->render($name . "[]", $id) . '&nbsp;' . $this->renderContentTag('a', 'x', array('class' => 'remove', 'href' => '#')), array('class' => 'taggable-tag-' . $id));
             }
         }
     }
     $content = $dropdown . $this->renderContentTag('ul', $content) . $this->getJavascriptBlock($name);
     return $this->renderContentTag('div', $content, array('id' => $this->generateId($name) . '_tagger', 'class' => 'taggable_container'));
 }
 public function getChoices()
 {
     $choices = parent::getChoices();
     $choices['other'] = 'その他';
     return $choices;
 }
<?php

$app = 'frontend';
$fixtures = 'fixtures/fixtures.yml';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(4);
// ->getChoices()
$t->diag('->getChoices()');
$validator = new sfWidgetFormDoctrineChoice(array('model' => 'Author'));
$author = Doctrine_Core::getTable('Author')->createQuery()->limit(1)->fetchOne();
$t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage', 2 => 'Fabien POTENCIER'), '->getChoices() returns choices');
$validator->setOption('order_by', array('name', 'asc'));
$t->cmp_ok($validator->getChoices(), '===', array(2 => 'Fabien POTENCIER', 1 => 'Jonathan H. Wage'), '->getChoices() returns ordered choices');
$validator->setOption('table_method', 'testTableMethod');
$t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage', 2 => 'Fabien POTENCIER'), '->getChoices() returns choices for given "table_method" option');
$validator = new sfWidgetFormDoctrineChoice(array('model' => 'Author', 'query' => Doctrine_Core::getTable('Author')->createQuery()->limit(1)));
$t->is_deeply($validator->getChoices(), array(1 => 'Jonathan H. Wage'), '->getChoices() returns choices for given "query" option');
 public function configure($options = array(), $attributes = array())
 {
     $this->addOption('maxPerPage', 10);
     parent::configure($options, $attributes);
     $this->pager->setMaxPerPage($this->getOption('maxPerPage'));
 }
Ejemplo n.º 11
0
$userCount = Doctrine_Query::create()->from('User u')->count();
$t->is($userCount, 1);
$profileCount = Doctrine_Query::create()->from('Profile p')->count();
$t->is($profileCount, 1);
$widget = new sfWidgetFormDoctrineChoice(array('model' => 'User'));
$t->is($widget->getChoices(), array(1 => 1));
$widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'key_method' => 'getUsername', 'method' => 'getPassword'));
$t->is($widget->getChoices(), array('jwage' => '4cb9c8a8048fd02294477fcb1a41191a'));
$widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'key_method' => 'getUsername', 'method' => 'getPassword'));
$t->is($widget->getChoices(), array('jwage' => '4cb9c8a8048fd02294477fcb1a41191a'));
$methods = array('widgetChoiceTableMethod1', 'widgetChoiceTableMethod2', 'widgetChoiceTableMethod3');
foreach ($methods as $method) {
    $widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'table_method' => $method));
    $t->is($widget->getChoices(), array(1 => 1));
}
$widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'table_method' => 'widgetChoiceTableMethod4'));
$t->is($widget->getChoices(), array());
$user = new User();
$user->Groups[]->name = 'User Group 1';
$user->Groups[]->name = 'User Group 2';
class UserGroupForm extends GroupForm
{
    public function configure()
    {
        parent::configure();
        $this->useFields(array('name'));
    }
}
$userForm = new UserForm($user);
$userForm->embedRelation('Groups', 'UserGroupForm');
$data = array('username' => 'jonwage', 'password' => 'changeme', 'Groups' => array(0 => array('name' => 'New User Group 1 Name'), 1 => array('name' => 'New User Group 2 Name')));
Ejemplo n.º 12
0
 /**
  * Récupère la liste des scénarios du projet en cours de visionnage.
  * @param sfWebRequest $request 
  */
 public function executeListScenarios(sfWebRequest $request)
 {
     $this->checkProject($request);
     //Recherche du projet
     //si le projet est renseigné
     $this->form = new sfForm();
     //mise en place du widget.
     $doctrineChoice = new sfWidgetFormDoctrineChoice(array('model' => 'EiScenario', 'add_empty' => '', 'query' => $this->ei_project->getScenariosQuery()));
     //si l'id scénario est renseigné, alors on sélectionne le
     //scénario en cours de visionnage.
     $ei_scenario_id = $request->getParameter('id');
     if (isset($ei_scenario_id)) {
         $doctrineChoice->setDefault($ei_scenario_id);
     }
     $this->form->setWidget('liste_scenario_choice', $doctrineChoice);
 }
 protected function configure($options = array(), $attributes = array())
 {
     $this->addOption('addWhere', null);
     parent::configure($options, $attributes);
 }
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('exclude', false);
 }
 /**
  * Constructor.
  *
  * @see sfWidgetFormDoctrineChoice
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->setOption('multiple', true);
 }
 /**
  * Available options:
  * 
  *  * group_by: The name of the relation to use for grouping
  * 
  * @see sfWidget
  */
 protected function configure($options = array(), $attributes = array())
 {
     $this->addRequiredOption('group_by');
     parent::configure($options, $attributes);
 }
 /**
  * Constructor.
  *
  * Available options:
  *
  *  * model:        The model class (required)
  *  * add_empty:    Whether to add a first empty value or not (false by default)
  *                  If the option is not a Boolean, the value will be used as the text value
  *  * method:       The method to use to display object values (__toString by default)
  *  * key_method:   The method to use to display the object keys (getPrimaryKey by default)
  *  * order_by:     An array composed of two fields:
  *                    * The column to order by the results (must be in the PhpName format)
  *                    * asc or desc
  *  * query:        A query to use when retrieving objects
  *  * multiple:     true if the select tag must allow multiple selections
  *  * table_method: A method to return either a query, collection or single object
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addOption('renderer_class', 'rtWidgetFormSelectCheckbox');
 }
Ejemplo n.º 18
0
<?php

slot('title');
?>
  <?php 
echo 'Online information of routes and itineraries - NoJam';
end_slot();
?>

<h1>Routes</h1>
<div class="column span-8 box">
    <div class="filter">
      <?php 
$select = new sfWidgetFormDoctrineChoice(array('model' => 'NjRoute', 'add_empty' => 'Select a route'), array('class' => 'select-box'));
echo $select->render('nj_route_id');
?>
      <?php 
$select = new sfWidgetFormSelect(array('choices' => $buses), array('class' => 'select-box'));
echo $select->render('buses_from_route');
?>
    </div>
    <br />
    <hr class="space"/>
    <div>
      <table>
        <thead>
          <th colspan="100%"><h2>Schedules</h2></th>
        </thead>
        <tfoot>
          <th colspan="100%">Schedules</th>
        </tfoot>