The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Dec 27, 2010 9:41 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Dec 27, 2010 8:44 am
Posts: 21
Hi folks,

I'm currently developing a template with many options for Joomla 1.6 and created some custom formfields for it.

Now I would like to access the values of other formfields of the templates parameters form from within the getInput() function of my custom formfield "savecolorpreset".

Is this possible? - I took a look at the sources of formfield.php and form.php and then thought,
Code:
$this->form->getValue('left_column_background_color');
should do the trick but it doesn't return any value.

Any hints?

Many thanks in advance for every reply,
yours Henri


Top
 Profile  
 
PostPosted: Sat Jan 01, 2011 9:03 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Dec 27, 2010 8:44 am
Posts: 21
Hi again folks,

I tried a lot of things, read the JForm API but could not get back a formfield-value with getValue(...).

But what now worked for me ist the following:
Code:
foreach($this->form->getFieldset() as $field) {
   if ( $field->name == $this->form->getFormControl() . '[params][body_background_color]' ) {
      $arrayColorFormfields[$field->name] = $field->value;
   }
}

I can get my things to work now but it would be nice if someone could even point me to the right direction to get back formfield values directly with getValue(...).

Yours Henri

_________________
| Daten- u. Netzwerkdesign für Internet und Intranet
| Installation & Pflege von Unternehmens-EDV-Strukturen
| Joomla Development, Extensions & Service-Provider
| http://joomla.byteconcepts.com


Top
 Profile  
 
PostPosted: Tue Feb 01, 2011 1:08 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Sat Sep 16, 2006 9:39 am
Posts: 59
Location: Alaska
Hi Byteconcepts,

Try putting this class above your JFormField extender class.

Code:
class Params {

   private $fields;
       
   public function __construct($fields) {
      $this->fields = $fields;
   }
   
   public function get($param) {
         
      foreach($this->fields as $field) {
         if ( $field->name == 'jform[params]['.$param.']' || $field->name == 'jform[params]['.$param.'][]' ) {
            return $field->value;
         }
      }
      
   }
   
}


With the above class added add the following to the beginning of your getInput() function.

Code:
$params = new Params($this->form->getFieldset());


Now all you need to get the value of a param in your getInput() function is something like the following.

Code:
echo $params->get('backgroundColor');



Oh and thanks for posting your initial code it helped send me in a functional direction. ;)

Also, I imagine, haven't tested, the above will work in other extended JFormField class functions just add

Code:
$params = new Params($this->form->getFieldset());


to them as well.

_________________
http://purpleirisdesign.com
http://niftychef.com


Top
 Profile  
 
PostPosted: Fri Jul 27, 2012 6:44 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jul 21, 2011 7:01 am
Posts: 6
just use:
$this->form->getValue('backgroundColor');


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 



Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group