Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have tried to follow your ideas as much as possible, so all the calls for the Counties, Towns and Postcodes are in the GeolocationMapper and the saving of the Image Data is in the ImageMapper.</p> <p>You asked of how I create my Form right now, here an example from my init() of the Form for the Counties etc...</p> <pre><code> // Create Dropdown for Counties $county = new Zend_Form_Element_Select('county'); $county-&gt;setLabel('Select a County') -&gt;setRegisterInArrayValidator(false) -&gt;setDecorators(array( 'ViewHelper', 'Errors', array('Description', array('tag' =&gt; 'p', 'class'=&gt;'description')), 'Label', array('HtmlTag', array('tag'=&gt;'li','class'=&gt;'county')) )) -&gt;setRequired(false); // Create Dropdown for Town $town = new Zend_Form_Element_Select('town'); $town-&gt;setRegisterInArrayValidator(false) -&gt;setDecorators(array( 'ViewHelper', 'Errors', array('Description', array('tag' =&gt; 'p', 'class' =&gt; 'description')), 'Label', array('HtmlTag',array('tag'=&gt;'li','class'=&gt;'town')) )); // Create Dropdown for Postcode $postcode = new Zend_Form_Element_Select('postcode'); $postcode-&gt;setRegisterInArrayValidator(false) -&gt;setDecorators(array( 'ViewHelper', 'Errors', array('Description', array('tag' =&gt; 'p', 'class' =&gt; 'description')), 'Label', array('HtmlTag',array('tag'=&gt;'li','class'=&gt;'postcode')) )) -&gt;setRegisterInArrayValidator(false); </code></pre> <p>In my Controller I than get the Elements and fill them:</p> <pre><code>$geolocationMapper = new Application_Model_GeolocationMapper(); $CountyOptions = $geolocationMapper-&gt;createCountyDropdown(); $form-&gt;getElement('county')-&gt;setMultiOptions($CountyOptions); </code></pre> <p>In my GeolocationMapper I have the Methods to build my Array of Counties:</p> <pre><code>/** =========================================================================== * Get Counties * @param * @return Object? of Counties * ========================================================================= */ public function getCountyList() { $table = $this-&gt;getDbTable(); $select = $table-&gt;select()-&gt;distinct() -&gt;from(array('p' =&gt; 'geolocation'),'county') -&gt;order('county'); $resultSet = $this-&gt;getDbTable()-&gt;fetchAll($select); $entries = array(); foreach ($resultSet as $row) { $entry = new Application_Model_Geolocation(); $entry-&gt;setId($row-&gt;county) -&gt;setCounty($row-&gt;county); $entries[] = $entry; } return $entries; } /** =========================================================================== * Create Array which will be used for Dropdown * @param * @return Array of Counties * ========================================================================= */ public function createCountyDropdown() { // List of Counties does not exist in Cache, read from DB if(!$CountyList = $this-&gt;getFromCache('counties')) { $CountyList = $this-&gt;getCountyList(); $Counties[''] = "Please choose"; foreach($CountyList as $value) { $Counties[str_replace(' ','_',$value-&gt;getCounty())] = $value-&gt;getCounty(); } $CountyDropdown = $Counties; // Save DB Result in Cache $this-&gt;addToCache ('counties',$CountyDropdown); return $CountyDropdown; }else{ return $this-&gt;getFromCache('counties'); } } </code></pre> <p>The Counties I read in my GeolocationMapper. The Towns and Postcodes get read when you choose a County, which than calls via Ajax the Geolocation Mapper and than createTownDropdown($county) and when a Town is choosen the same procedure but an Ajax call for loadPostcodes() and there createPostcodeDropdown($town).</p> <p>Does this all sounds correct or any suggestions how I could improve this?</p> <p>I am sorry but I would really like to add another question since I can't find an answer anywhere... I also have an Image Upload which works via Ajax and jQuery. When you choose an Image to upload, the Image gets straight displayed. For this I create dynamically an input Element with an image src. I have not found ny other way to add Images otherwise to Zend Form. Is there a possibility to add an Image to display the image as a normal ? It would be just a lot easier to have a img, since I would like to use jQuery Drag and Drop. Thanks so much for your help so far !!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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