Re: [PHPTAL] Radio Buttons & selection box

2008-06-30 Thread Kornel Lesiński

Dnia 29-06-2008 o 05:56:33 Levi Stanley <[EMAIL PROTECTED]> napisał(a):


Or you can do it like the method below, however I was wondering if there
is a better way than doing it like this?


You could solve it like this:

$phptal->best_times_to_call = array('Morning','Evening');
tal:content="opt" />


tal:attributes is smart enough to generate selected and checked attributes  
properly for XHTML.



Choose Time



BTW:  in  is not allowed. You should at least add  
tal:omit-tag="" or best use , which is "invisible".


--
regards, Kornel

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Radio Buttons & selection box

2008-06-29 Thread Rafał Miłecki
2008/6/29, Levi Stanley <[EMAIL PROTECTED]>:
> Was wondering if there was a better way to deal with radio buttons &
>  selection box in phptal.
>
>  One way, is make an array, and pass it the choices to the template.
>
>  Or you can do it like the method below, however I was wondering if there
>  is a better way than doing it like this?


First of all you are not allowed to put "span" inside "select"
element. For such things like grouping, please use tal:block.

...

This is element that will be removed before generating output (but of
course respected by parser).


I don't have any really clean solution for selects. I use something like this:

no
maybe
yes


no = false;
$template->maybe = true;
$template->yes = false;
?>

PHPTAL converts this to nice XHTML (selected="selected").

-- 
Rafał Miłecki
___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


Re: [PHPTAL] Radio Buttons & selection box

2008-06-29 Thread Werner

Hi Levi

I'm posting an extract from one of my previous posts, I think it might 
give you an additional perspective to get out of the "tal:conditional" 
grip in your template code..?


--- Begin Quote ---

There are two ways that you can achieve the desired result:

1) The TAL-complaint way is to flag the selected state in your category 
list, thus in your source object:


$categoryList = array(
  ...
  array(
 id => 123,
 name => 'My Category',
 selected => false
  ),
  array(
 id => 456,
 name => 'My Other Category',
 selected => true
  ),
  ...
);

Then your PHPTAL code is as simple as:


  
  



2) The other option (I sometimes need to use this approach) is to write 
your own custom modifier, that compares the object's value to another 
value. Note: This, however, is NOT TAL compliant and will make your 
template code specific to PHPTAL and thus your templates will not be 
portable to other TAL implementations.


Here is an example modifier:

function phptal_tales_match($src, $nothrow) {
  $srcArr = explode(',', trim($src));
  if (count($srcArr) == 2) {
  return '(' . PHPTAL_TalesInternal::path($srcArr[0], $nothrow) .' 
== '. PHPTAL_TalesInternal::path($srcArr[1], $nothrow) . ')';

  } else {
  return PHPTAL_TalesInternal::path($src, $nothrow);
  }
}

This modifier, when included before you initiate a PHPTAL object, can be 
used as follows:



tal:attributes="selected match:category/id,article/category; 
value category/id"

  tal:content="category/name">
  


--- End Quote ---


Levi Stanley wrote:

Was wondering if there was a better way to deal with radio buttons &
selection box in phptal.

One way, is make an array, and pass it the choices to the template.

Or you can do it like the method below, however I was wondering if there
is a better way than doing it like this?

Choose Time

Morning
Morning
Evening
Evening


Morning
Evening



Best regards,
Levi

___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

  



___
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal