Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Conditions in a setFieldFormatting


Reply


3 Posts   2257 Views

Avatar
Ney

Community Member, 8 Posts

21 June 2008 at 1:08am

hello guys I need your help!! I wanna put a condition in a setFieldFormatting of a ComplexTableField but my condition isn't working it is my code:
$Currency = new ComplexTableField(
      $this,
      'Currencies', // relation name
      'CurrencyP', // object class
      array(
            'Currency_Iso'=>'Currency Iso',
            'Currency_Name'=>'Currency Name',
            'Currency_Symbol'=>'Currency Symbol',
            'Price'=>'Price',
            'Number_Format'=>'Format',
            'Currency_Default'=>'Currency Default',
            "Active_Inactive" => "Active Inactive"
            ), // fields to show in table
      "getCMSFields_forPopup" // form that pops up for edit
      );
            
      
$Currency->setFieldFormatting(array('Currency_Default'=>'<input type=\"radio\" name=\"default\" value=\"$ID\"'.('$Currency_Default'=='1'?' checked="checked':' ').'>$ID' ));

Avatar
carlossg

Community Member, 13 Posts

11 August 2008 at 12:08pm

Hi Ney.

Did you fix that problem?, i'm dealing with something similar, but much simpler and i got to the point that source fields can't be referred that easy

$MyTable = new ComplexTableField(
$this,
'MyRelationName', // relation name
'MyObjectClass', // object class
array(
'Time'=>'Time_Label',
'Date'=>'Date_Label',
), // fields to show in table
"getCMSFields_forPopup" // form that pops up for edit
);

$MyTable->setFieldFormatting(array('Time'=>$Time)); //obviously i don't want to do this!!

I want to use php date_format function to reformat time i the ComplexTableField but $Time variable gets NULL.

Any idea?

Thanks in advanced.

Avatar
Ingo

Forum Moderator, 801 Posts

14 August 2008 at 11:06pm

how about a (kinda presentational) getter on your model instead? its not pretty, but does the job... alternatively you could sublcass ComplexTableField with a custom template.

class CurrencyP {
function getCurrencyDefaultChecked() {
return ($this->Currency_Default) ? 'checked' : '';
}
}

$Currency = new ComplexTableField(
$this,
'Currencies', // relation name
'CurrencyP', // object class
array(
'Currency_Iso'=>'Currency Iso',
'Currency_Name'=>'Currency Name',
'Currency_Symbol'=>'Currency Symbol',
'Price'=>'Price',
'Number_Format'=>'Format',
'CurrencyDefaultHTML'=>'Currency Default',
"Active_Inactive" => "Active Inactive"
), // fields to show in table
"getCMSFields_forPopup" // form that pops up for edit
);
$Currency->setFieldFormatting(array('Currency_Default'=>'<input type=\"radio\" name=\"default\" value=\"$ID\" checked=\"$CurrencyDefaultChecked\">$ID' ));