Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The formatter is used to render the whole form, what you need is to change the rendering of one of the widgets.</p> <p>The <code>sfwidgetFormDoctrineChoice</code> has an option <code>renderer</code> which takes a formatter as an argument. The one that you need is the <code>sfWidgetFormSelectCheckbox</code>. What I would do is:</p> <ol> <li><p>create your own class which will extend the <code>sfWidgetFormSelectCheckbox</code> class. E.g.</p> <pre><code>class sfWidgetFormMySelectWithThumbs extends sfWidgetFormSelectCheckbox { } </code></pre></li> <li><p>Extend the <code>configure</code> function so it takes another option which will hold an array of your thumbnails.</p> <pre><code>public function configure($options = array(), $arguments = array()) { parent::configure($options, $arguments); $this-&gt;addOption('thumbnails', array()); } </code></pre></li> <li><p>Change the <code>formatChoices</code> function so it adds the image in front of the checkbox (you can copy and modify the original <code>formatChoices</code> function).</p> <pre><code>... $sources = $this-&gt;getOption('thumbnails'); ... $inputs[$id] = array( 'input' =&gt; sprintf('| %s | %s', $this-&gt;renderTag('img', array('src' =&gt; $sources[$key])), $this-&gt;renderTag('input', array_merge($baseAttributes, $attributes)) ), 'label' =&gt; $this-&gt;renderContentTag('label', self::escapeOnce($option), array('for' =&gt; $id)), ); </code></pre></li> <li><p>Use the formatter class in your widget:</p> <pre><code> $this-&gt;setWidget('bulkUploadVideos', new sfWidgetFormDoctrineChoice(array( ... 'renderer' =&gt; new sfWidgetFormMySelectWithThumbs(array('thumbnails' =&gt; $thumbanils)) ) )); </code></pre> <p>Of course you need to retrieve the list of thumbnails as an array where the array keys are the same as the id's used for values for the checkboxes, but that shouldn't be an issue.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload