Re[2]: [SMARTY] Default variable values for forms

From: Date: Sun, 23 Jun 2002 20:33:09 +0000
Subject: Re[2]: [SMARTY] Default variable values for forms
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4980@lists.php.net to get a copy of this message
Hi! this is great, this could be done by those who program smarty and realy don't know why then don't. I like clean code not some workaround with setting error reporting. Does this pathc work with some stable release. -- bye, Uros mailto:uros.gruber@sir-mag.com Sunday, June 23, 2002, 10:21:14 PM, you wrote: JA> Hi, JA> On Sat, Jun 22, 2002 at 03:25:34PM +0200, Lech Rychliñski wrote: >> manual says that i can do sth like this: >> >> <input type="text" name="name" value={$post.name|default:"&nbsp;"}> >> >> but in fact it doesn't change anything because I see error about name >> index again. i've tried even sth like this: JA> if you have error reporting set to E_ALL you might get some errors here JA> and there, for example when using default. Below are the changes I had JA> to do to Smarty_Compiler.class.php (from Smarty CVS as of this evening) JA> to get default to work with error reporting set to E_ALL. JA> The beginning of the patch, until the _run_mod_handler part is for some JA> other problems I had because I have error reporting set to E_ALL. JA> If you don't feel like using my ugly workaround you can always change JA> your error reporting level to E_ALL & ~E_NOTICE (which is the default JA> setting in PHP 4) and then default should work without any problems. JA> Regards, JA> Joakim JA> --- Smarty_Compiler.class.php.org Sun Jun 23 22:54:07 2002 JA> +++ Smarty_Compiler.class.php Sun Jun 23 23:18:47 2002 JA> @@ -962,7 +962,7 @@ JA> switch ($expr_type) { JA> case 'even': JA> - if (@$tokens[$expr_end] == 'by') { JA> + if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { JA> $expr_end++; JA> $expr_arg = $tokens[$expr_end++]; JA> $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; JA> @@ -971,7 +971,7 @@ JA> break; JA> case 'odd': JA> - if (@$tokens[$expr_end] == 'by') { JA> + if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { JA> $expr_end++; JA> $expr_arg = $tokens[$expr_end++]; JA> $expr = "(($is_arg / $expr_arg) % $expr_arg)"; JA> @@ -980,7 +980,7 @@ JA> break; JA> case 'div': JA> - if (@$tokens[$expr_end] == 'by') { JA> + if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') { JA> $expr_end++; JA> $expr_arg = $tokens[$expr_end++]; JA> $expr = "!($is_arg % $expr_arg)"; JA> @@ -1244,6 +1244,11 @@ JA> else JA> $modifier_args = ''; JA> + // UGLY WORKAROUND BY ME JA> + if ($modifier_name == 'default') JA> + { JA> + $output = "isset($output) ? $output : NULL"; JA> + } JA> $output = "\$this->_run_mod_handler('$modifier_name', $map_array, $output$modifier_args)"; JA> } JA> } JA> -- JA> Joakim Andersson ; tyrak@borgship.net ; http://borgship.net/~tyrak/

« previous php.smarty.general (#4980) next »