SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: (joomla issue)

  1. #1
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    (joomla issue) custom param type

    I have posted this in joomla forum but noone seems to have an answer, hopefully someone here will know.

    I am trying to setup a new custom parameter type to lear how it is done but with little succes I am setting up a select field, I know it is already available in joomla as a list param type but I am doing it for learning purpouses.

    Here is the code I have

    Code PHP:
    <?php
    defined('JPATH_BASE') or die;
    jimport('joomla.html.html');
    jimport('joomla.form.formfield');
    class JFormFieldTestselect extends JFormField{
    protected $type = 'Testselect';
    protected function getInput(){
    $name = $this->element['name'];
    $id = $this->element['id'];
    $default = $this->element['default'];
    $size = (int)$this->element['size'];
    $this_counter = 0;
    $measuring_type = $this->element['measuring_type'];
    $pixels_16 = array ('40px', '100px', '160px', '220px', '280px', '340px', '400px', '460px', '520px', '580px', '640px', '700px', '760px', '820px', '880px', '940px');
    $array_values = array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
    $measuring;
    $options;
    if ($measuring_type == 'pixels'){
    $measuring = $pixels_16;
    }
    else if ($measuring_type == 'normal'){
    $measuring = $array_values;
    }
    while ($size > 0){
    $options = $options . '<option value="' . $array_values[$this_counter] . '">' . $measuring[$this_counter] . '</option>';
    $this_counter ++;
    $size --;
    }
    $this_counter = 0;
    $return = '<select id="' . $id . '" name="' . $name . '" default="' . $default . '" >' .  $options . '</select>';
    return $return;
    }
    }
    ?>

    The above does create the select field as I expect, it provides a dropdown selectbox with the needed options, the specified within the xml manifest.

    when I select the option in the select field and hit save to save the extension configuration changes nothing is saved in the database, can someone help with this?
    Last edited by tlacaelelrl; Jun 9, 2011 at 20:26. Reason: Post title did not explain the issue

  2. #2
    SitePoint Addict tlacaelelrl's Avatar
    Join Date
    Apr 2011
    Location
    Mexico city, Mexico
    Posts
    353
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    here is how I made it save the info in the database

    Code PHP:
    <?php
    defined('JPATH_BASE') or die;
    jimport('joomla.html.html');
    jimport('joomla.form.formfield');
    class JFormFieldTlak extends JFormField{
    protected $type = 'Tlak';
    protected function getInput(){
    $name = $this->element['name'];
    $id = $this->element['id'];
    $default = $this->element['default'];
    $size = (int)$this->element['size'];
    $this_counter = 0;
    $measuring_type = $this->element['measuring_type'];
    $pixels_16 = array ('40px', '100px', '160px', '220px', '280px', '340px', '400px', '460px', '520px', '580px', '640px', '700px', '760px', '820px', '880px', '940px');
    $array_values = array (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
    $measuring;
    $options;
    if ($measuring_type == 'pixels'){
    $measuring = $pixels_16;
    }
    else if ($measuring_type == 'normal'){
    $measuring = $array_values;
    }
    while ($size > 0){
    $options = $options . '<option value="' . $array_values[$this_counter] . '">' . $measuring[$this_counter] . '</option>';
    $this_counter ++;
    $size --;
    }
    $this_counter = 0;
    $return = '<select id="jform_params_' . $id . '" name="jform[params][' . $name . ']" >' .  $options . '</select>';
    return $return;
    }
    }
    ?>

  3. #3
    SitePoint Zealot RishikeshJha's Avatar
    Join Date
    Mar 2009
    Location
    INDIA
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where is your xml file?
    Rishi


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •