[symfony-users] Re: Indicator for required fields

2009-03-02 Thread Lee Bolding

Please, explain why.

This should be interesting :)

- Original Message -
From: avorobiev vorobiev.alexan...@gmail.com
To: symfony users symfony-users@googlegroups.com
Sent: Monday, 2 March, 2009 7:02:24 AM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: [symfony-users] Re: Indicator for required fields


You shoudn't use css property for required field marking...

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-03-01 Thread avorobiev

You shoudn't use css property for required field marking..., but you
can replace css class on any html.
I am using nex solution:
1. Modify base form class lib/form/doctrine/BaseFormDoctrine.class.php
abstract class BaseFormDoctrine extends sfFormDoctrine
{
  const REQUIRED_CLASS_NAME = 'required';

  public function __construct($object = null, $options = array(),
$CSRFSecret = null)
  {
parent::__construct($object, $options, $CSRFSecret);

$this-postSetup();
  }

  public function setup()
  {
  }

  /**
   * Post setup final method, cannot be overriden
   *
   */
  final private function postSetup()
  {
$this-handleRequiredFields();
  }

  /**
   * Adds a CSS class name to required widgets
   *
   */
  protected function handleRequiredFields()
  {
if (!$this-validatorSchema)
{
  return;
}

foreach ($this-validatorSchema-getFields() as $fieldName =
$validator)
{
  /* @var $validator sfValidatorBase */
  if (true === $validator-getOption('required'))
  {
if (!array_key_exists($fieldName, $this-widgetSchema-
getFields()))
{
  continue;
}

/* @var $widget sfWidget */
$widget = $this-widgetSchema[$fieldName];

$class = trim($widget-getAttribute('class'));

if (false===strpos($class, self::REQUIRED_CLASS_NAME))
{
  $class = sprintf('%s %s', $class,
self::REQUIRED_CLASS_NAME);
  $widget-setAttribute('class', $class);
}
  }
}
  }
}

2. Create your custom schema formater:
class sfWidgetFormSchemaFormatterRequired extends
sfWidgetFormSchemaFormatter
{
  public function formatRow($label, $field, $errors = array(), $help =
'', $hiddenFields = null)
  {
return strtr($this-getRowFormat(), array(
  '%errorclass%'= (count($errors) ?' class=error' : ''),
  '%required%'  = (false!==strpos($field, 'required') ?
'span*/span' : ''), // Look here! This is the place where added
asterisk. You can add your own code.
  '%label%' = $label,
  '%field%' = $field,
  '%error%' = $this-formatErrorsForRow($errors),
  '%help%'  = $this-formatHelp($help),
  '%hidden_fields%' = is_null($hiddenFields) ? '%hidden_fields
%' : $hiddenFields,
));
  }
}

3. In the form add form formatter:
classYourForm extends BaseFormDoctrine
{
 public function setup()
  {
...
$this-widgetSchema-setDefaultFormFormatterName('Required');
...
  }
}

All of this steps was described at the link
http://groups.google.com/group/symfony-devs/browse_thread/thread/4c81264521f8bc60

On Feb 26, 1:42 pm, Tomasz Ignatiuk tomek.ignat...@gmail.com wrote:
 It is not good solution because using css pre doesn't work in
 IE...which is used byI don't know...50% of users?

 On 26 Lut, 06:58, avorobiev vorobiev.alexan...@gmail.com wrote:

  Look 
  athttp://groups.google.com/group/symfony-devs/browse_thread/thread/4c81...

  On Feb 24, 2:20 pm, Tomasz Ignatiuk tomek.ignat...@gmail.com wrote:

   On 16 Sty, 13:35, Thomas Dedericks tho...@tequila-studio.com wrote:

Hi,

Not tested:

public function configure() {

        ...

        # add * torequiredfields' labels:
        foreach ($this-widgetSchema as $name = $widget)
        {
                if (isset($this-validatorSchema[$name])  
$this-validatorSchema[$name]-hasOption('required')  
$this-validatorSchema[$name]-getOption('required') == true)
                {
                        $label = ($widget-getLabel() != null) ? 
$widget-getLabel() : $name;
                        $widget-setLabel($label.' *');
                }
        }

}

Thomas Dedericks

   Unfortunatelly it doesn't work. But if you do some stuff before and
   with little change...it works :)
   1. Required option is true as default. I don't know why it isn't set
   in widgetSchema. So this won't work: 
   $this-validatorSchema[$name]-hasOption('required')  
   $this-validatorSchema[$name]-getOption

   ('required') == true
   2. If label is set in generator.yml, it isn't  set in widgetSchema, so
   $widget-getLabel() != null is always null You have to set it manually
   in configure()
   3. widgetSchema i a set of objects, not name fields, so you have to
   add this:   foreach ($this-widgetSchema-getFields() as $name =
   $widget)

   So you have to set labels for requried fields in configure() of a form
   and for some fields, like boolean you have to add manually required to
   true, like this: $this-validatorSchema['master'] = new
   sfValidatorBoolean(array('required' = true)); And also change this:
$this-validatorSchema[$name]-getOption('required') != false).
   required != false

       foreach ($this-widgetSchema-getFields() as $name = $widget)
       {
         if (isset($this-validatorSchema[$name])  
   $this-validatorSchema[$name]-hasOption('required')  $this-
   validatorSchema[$name]-getOption('required') != false)

         {
     

[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Paolo Mainardi
It's sad to say, but i think that wthis Form Framework is Overengineering,
Overcomplicated, Less documented and don't take care of this basic
behaviour, this problem is an example.

It's possible to have a complete Form Framework like this and discuss on *
to put on required fields ? I don't think, we have some big problems, for
Symfony 1.3 i hope for a big human refactoring of Form Framework :(

On Thu, Feb 26, 2009 at 11:42 AM, Tomasz Ignatiuk
tomek.ignat...@gmail.comwrote:


 It is not good solution because using css pre doesn't work in
 IE...which is used byI don't know...50% of users?

 On 26 Lut, 06:58, avorobiev vorobiev.alexan...@gmail.com wrote:
  Look athttp://
 groups.google.com/group/symfony-devs/browse_thread/thread/4c81...
 
  On Feb 24, 2:20 pm, Tomasz Ignatiuk tomek.ignat...@gmail.com wrote:
 
   On 16 Sty, 13:35, Thomas Dedericks tho...@tequila-studio.com wrote:
 
Hi,
 
Not tested:
 
public function configure() {
 
...
 
# add * torequiredfields' labels:
foreach ($this-widgetSchema as $name = $widget)
{
if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption('required') == true)
{
$label = ($widget-getLabel() != null) ?
 $widget-getLabel() : $name;
$widget-setLabel($label.' *');
}
}
 
}
 
Thomas Dedericks
 
   Unfortunatelly it doesn't work. But if you do some stuff before and
   with little change...it works :)
   1. Required option is true as default. I don't know why it isn't set
   in widgetSchema. So this won't work:
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption
 
   ('required') == true
   2. If label is set in generator.yml, it isn't  set in widgetSchema, so
   $widget-getLabel() != null is always null You have to set it manually
   in configure()
   3. widgetSchema i a set of objects, not name fields, so you have to
   add this:   foreach ($this-widgetSchema-getFields() as $name =
   $widget)
 
   So you have to set labels for requried fields in configure() of a form
   and for some fields, like boolean you have to add manually required to
   true, like this: $this-validatorSchema['master'] = new
   sfValidatorBoolean(array('required' = true)); And also change this:
$this-validatorSchema[$name]-getOption('required') != false).
   required != false
 
   foreach ($this-widgetSchema-getFields() as $name = $widget)
   {
 if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required')  $this-
   validatorSchema[$name]-getOption('required') != false)
 
 {
   $label = ($widget-getLabel() != null) ? $widget-getLabel() :
   $name;
   $widget-setLabel($label.' *');
 }
   }
 
   All in all it is faster just to add * manually for required fields:
   $this-widgetSchema-setLabels(array(
   'logo' = 'Logo *',
   'name' = 'Name *',
   'master' = 'Master *',
   ));
 



-- 
Paolo Mainardi

Vice Presidente Assoc.ILDN (http://www.ildn.net)
Blog: http://www.paolomainardi.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Tomasz Ignatiuk
It is not perfect but I don't think it is:  Form Framework is
Overengineering, Overcomplicated, Less documented


2009/2/26 Paolo Mainardi paolomaina...@gmail.com

 It's sad to say, but i think that wthis Form Framework is Overengineering,
 Overcomplicated, Less documented and don't take care of this basic
 behaviour, this problem is an example.

 It's possible to have a complete Form Framework like this and discuss on
 * to put on required fields ? I don't think, we have some big problems,
 for Symfony 1.3 i hope for a big human refactoring of Form Framework :(


 On Thu, Feb 26, 2009 at 11:42 AM, Tomasz Ignatiuk 
 tomek.ignat...@gmail.com wrote:


 It is not good solution because using css pre doesn't work in
 IE...which is used byI don't know...50% of users?

 On 26 Lut, 06:58, avorobiev vorobiev.alexan...@gmail.com wrote:
  Look athttp://
 groups.google.com/group/symfony-devs/browse_thread/thread/4c81...
 
  On Feb 24, 2:20 pm, Tomasz Ignatiuk tomek.ignat...@gmail.com wrote:
 
   On 16 Sty, 13:35, Thomas Dedericks tho...@tequila-studio.com wrote:
 
Hi,
 
Not tested:
 
public function configure() {
 
...
 
# add * torequiredfields' labels:
foreach ($this-widgetSchema as $name = $widget)
{
if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption('required') == true)
{
$label = ($widget-getLabel() != null) ?
 $widget-getLabel() : $name;
$widget-setLabel($label.' *');
}
}
 
}
 
Thomas Dedericks
 
   Unfortunatelly it doesn't work. But if you do some stuff before and
   with little change...it works :)
   1. Required option is true as default. I don't know why it isn't set
   in widgetSchema. So this won't work:
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption
 
   ('required') == true
   2. If label is set in generator.yml, it isn't  set in widgetSchema, so
   $widget-getLabel() != null is always null You have to set it manually
   in configure()
   3. widgetSchema i a set of objects, not name fields, so you have to
   add this:   foreach ($this-widgetSchema-getFields() as $name =
   $widget)
 
   So you have to set labels for requried fields in configure() of a form
   and for some fields, like boolean you have to add manually required to
   true, like this: $this-validatorSchema['master'] = new
   sfValidatorBoolean(array('required' = true)); And also change this:
$this-validatorSchema[$name]-getOption('required') != false).
   required != false
 
   foreach ($this-widgetSchema-getFields() as $name = $widget)
   {
 if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required')  $this-
   validatorSchema[$name]-getOption('required') != false)
 
 {
   $label = ($widget-getLabel() != null) ? $widget-getLabel() :
   $name;
   $widget-setLabel($label.' *');
 }
   }
 
   All in all it is faster just to add * manually for required fields:
   $this-widgetSchema-setLabels(array(
   'logo' = 'Logo *',
   'name' = 'Name *',
   'master' = 'Master *',
   ));




 --
 Paolo Mainardi

 Vice Presidente Assoc.ILDN (http://www.ildn.net)
 Blog: http://www.paolomainardi.com


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Lee Bolding

I don't understand why you don't just give it a CSS class of 'required' - that 
way it's not 'fixed' as any particular character, and there are no I18N or 
accessibility issues.

Seems like the most obvious answer to me (same as when I said this about 4 
weeks ago when this first came up)

- Original Message -
From: Paolo Mainardi paolomaina...@gmail.com
To: symfony-users@googlegroups.com
Sent: Thursday, February 26, 2009 11:01:19 AM GMT +00:00 GMT Britain, Ireland, 
Portugal
Subject: [symfony-users] Re: Indicator for required fields

It's sad to say, but i think that wthis Form Framework is Overengineering, 
Overcomplicated, Less documented and don't take care of this basic behaviour, 
this problem is an example. 

It's possible to have a complete Form Framework like this and discuss on * to 
put on required fields ? I don't think, we have some big problems, for Symfony 
1.3 i hope for a big human refactoring of Form Framework :( 


On Thu, Feb 26, 2009 at 11:42 AM, Tomasz Ignatiuk  tomek.ignat...@gmail.com  
wrote: 



It is not good solution because using css pre doesn't work in 
IE...which is used byI don't know...50% of users? 

On 26 Lut, 06:58, avorobiev  vorobiev.alexan...@gmail.com  wrote: 
 Look athttp:// 
 groups.google.com/group/symfony-devs/browse_thread/thread/4c81. .. 
 
 On Feb 24, 2:20 pm, Tomasz Ignatiuk  tomek.ignat...@gmail.com  wrote: 
 
  On 16 Sty, 13:35, Thomas Dedericks  tho...@tequila-studio.com  wrote: 
 
   Hi, 
 
   Not tested: 
 
   public function configure() { 
 
   ... 
 
   # add * torequiredfields' labels: 
   foreach ($this-widgetSchema as $name = $widget) 
   { 
   if (isset($this-validatorSchema[$name])  
   $this-validatorSchema[$name]-hasOption('required')  
   $this-validatorSchema[$name]-getOption('required') == true) 
   { 
   $label = ($widget-getLabel() != null) ? $widget-getLabel() : $name; 
   $widget-setLabel($label.' *'); 
   } 
   } 
 
   } 
 
   Thomas Dedericks 
 
  Unfortunatelly it doesn't work. But if you do some stuff before and 
  with little change...it works :) 
  1. Required option is true as default. I don't know why it isn't set 
  in widgetSchema. So this won't work: 
  $this-validatorSchema[$name]-hasOption('required')  
  $this-validatorSchema[$name]-getOption 
 
  ('required') == true 
  2. If label is set in generator.yml, it isn't set in widgetSchema, so 
  $widget-getLabel() != null is always null You have to set it manually 
  in configure() 
  3. widgetSchema i a set of objects, not name fields, so you have to 
  add this: foreach ($this-widgetSchema-getFields() as $name = 
  $widget) 
 
  So you have to set labels for requried fields in configure() of a form 
  and for some fields, like boolean you have to add manually required to 
  true, like this: $this-validatorSchema['master'] = new 
  sfValidatorBoolean(array('required' = true)); And also change this: 
   $this-validatorSchema[$name]-getOption('required') != false). 
  required != false 
 
  foreach ($this-widgetSchema-getFields() as $name = $widget) 
  { 
  if (isset($this-validatorSchema[$name])  
  $this-validatorSchema[$name]-hasOption('required')  $this- 
  validatorSchema[$name]-getOption('required') != false) 
 
  { 
  $label = ($widget-getLabel() != null) ? $widget-getLabel() : 
  $name; 
  $widget-setLabel($label.' *'); 
  } 
  } 
 
  All in all it is faster just to add * manually for required fields: 
  $this-widgetSchema-setLabels(array( 
  'logo' = 'Logo *', 
  'name' = 'Name *', 
  'master' = 'Master *', 
  )); 




-- 
Paolo Mainardi 

Vice Presidente Assoc.ILDN ( http://www.ildn.net ) 
Blog: http://www.paolomainardi.com 



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Tomasz Ignatiuk
why you don't just give it a CSS class of 'required'
You ask this question to whom? Me? Users or Symfony Developers?

Class required doesn't solve everything. With this you can only make a label
different color or something. In 1.3 there should be a way to enter your own
character before or after label, before or after input and a class
'required' for label and input.

For now, the fastest way is to add your own character in label by setting a
label in configure().

2009/2/26 Lee Bolding l...@leesbian.net


 I don't understand why you don't just give it a CSS class of 'required' -
 that way it's not 'fixed' as any particular character, and there are no I18N
 or accessibility issues.

 Seems like the most obvious answer to me (same as when I said this about 4
 weeks ago when this first came up)

 - Original Message -
 From: Paolo Mainardi paolomaina...@gmail.com
 To: symfony-users@googlegroups.com
 Sent: Thursday, February 26, 2009 11:01:19 AM GMT +00:00 GMT Britain,
 Ireland, Portugal
 Subject: [symfony-users] Re: Indicator for required fields

 It's sad to say, but i think that wthis Form Framework is Overengineering,
 Overcomplicated, Less documented and don't take care of this basic
 behaviour, this problem is an example.

 It's possible to have a complete Form Framework like this and discuss on
 * to put on required fields ? I don't think, we have some big problems,
 for Symfony 1.3 i hope for a big human refactoring of Form Framework :(


 On Thu, Feb 26, 2009 at 11:42 AM, Tomasz Ignatiuk 
 tomek.ignat...@gmail.com  wrote:



 It is not good solution because using css pre doesn't work in
 IE...which is used byI don't know...50% of users?

 On 26 Lut, 06:58, avorobiev  vorobiev.alexan...@gmail.com  wrote:
  Look athttp://
 groups.google.com/group/symfony-devs/browse_thread/thread/4c81. ..
 
  On Feb 24, 2:20 pm, Tomasz Ignatiuk  tomek.ignat...@gmail.com  wrote:
 
   On 16 Sty, 13:35, Thomas Dedericks  tho...@tequila-studio.com 
 wrote:
 
Hi,
 
Not tested:
 
public function configure() {
 
...
 
# add * torequiredfields' labels:
foreach ($this-widgetSchema as $name = $widget)
{
if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption('required') == true)
{
$label = ($widget-getLabel() != null) ? $widget-getLabel() : $name;
$widget-setLabel($label.' *');
}
}
 
}
 
Thomas Dedericks
 
   Unfortunatelly it doesn't work. But if you do some stuff before and
   with little change...it works :)
   1. Required option is true as default. I don't know why it isn't set
   in widgetSchema. So this won't work:
 $this-validatorSchema[$name]-hasOption('required') 
 $this-validatorSchema[$name]-getOption
 
   ('required') == true
   2. If label is set in generator.yml, it isn't set in widgetSchema, so
   $widget-getLabel() != null is always null You have to set it manually
   in configure()
   3. widgetSchema i a set of objects, not name fields, so you have to
   add this: foreach ($this-widgetSchema-getFields() as $name =
   $widget)
 
   So you have to set labels for requried fields in configure() of a form
   and for some fields, like boolean you have to add manually required to
   true, like this: $this-validatorSchema['master'] = new
   sfValidatorBoolean(array('required' = true)); And also change this:
$this-validatorSchema[$name]-getOption('required') != false).
   required != false
 
   foreach ($this-widgetSchema-getFields() as $name = $widget)
   {
   if (isset($this-validatorSchema[$name]) 
 $this-validatorSchema[$name]-hasOption('required')  $this-
   validatorSchema[$name]-getOption('required') != false)
 
   {
   $label = ($widget-getLabel() != null) ? $widget-getLabel() :
   $name;
   $widget-setLabel($label.' *');
   }
   }
 
   All in all it is faster just to add * manually for required fields:
   $this-widgetSchema-setLabels(array(
   'logo' = 'Logo *',
   'name' = 'Name *',
   'master' = 'Master *',
   ));




 --
 Paolo Mainardi

 Vice Presidente Assoc.ILDN ( http://www.ildn.net )
 Blog: http://www.paolomainardi.com



 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Paolo Mainardi
On Thu, Feb 26, 2009 at 12:04 PM, Tomasz Ignatiuk
tomek.ignat...@gmail.comwrote:

 It is not perfect but I don't think it is:  Form Framework is
 Overengineering, Overcomplicated, Less documented


We are discussing on how to set a marker of required fields and at the
final we are arrived to the better thing is to set the labels manually, we
must think at this, i know that is a young framework but there are some
portion of code that could be simplified, we need a smarter form framework
like all the rest of Framework.

We should start discussing on how to improve this things for Symfony 1.3.


-- 
Paolo Mainardi

Vice Presidente Assoc.ILDN (http://www.ildn.net)
Blog: http://www.paolomainardi.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Tomasz Ignatiuk
http://www.symfony-project.org/blog/2009/01/25/about-symfony-1-3

2009/2/26 Paolo Mainardi paolomaina...@gmail.com



 On Thu, Feb 26, 2009 at 12:04 PM, Tomasz Ignatiuk 
 tomek.ignat...@gmail.com wrote:

 It is not perfect but I don't think it is:  Form Framework is
 Overengineering, Overcomplicated, Less documented


 We are discussing on how to set a marker of required fields and at the
 final we are arrived to the better thing is to set the labels manually, we
 must think at this, i know that is a young framework but there are some
 portion of code that could be simplified, we need a smarter form framework
 like all the rest of Framework.

 We should start discussing on how to improve this things for Symfony 1.3.



 --
 Paolo Mainardi

 Vice Presidente Assoc.ILDN (http://www.ildn.net)
 Blog: http://www.paolomainardi.com

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Lee Bolding

I ask anybody and everybody :)

You can use CSS and JQuery to add whatever decoration you want before and after 
the required label. Take a look, there's a lot more possible with CSS than just 
making a label a different color ;)

Adding any hardcoded characters is just plain dumb, it introduces a whole load 
of new problems, and it's totally not flexible. 

It's not 1994 anymore.

- Original Message -
From: Tomasz Ignatiuk tomek.ignat...@gmail.com
To: symfony-users@googlegroups.com
Sent: Thursday, February 26, 2009 11:13:35 AM GMT +00:00 GMT Britain, Ireland, 
Portugal
Subject: [symfony-users] Re: Indicator for required fields

why you don't just give it a CSS class of 'required' 
You ask this question to whom? Me? Users or Symfony Developers? 

Class required doesn't solve everything. With this you can only make a label 
different color or something. In 1.3 there should be a way to enter your own 
character before or after label, before or after input and a class 'required' 
for label and input. 

For now, the fastest way is to add your own character in label by setting a 
label in configure(). 


2009/2/26 Lee Bolding  l...@leesbian.net  



I don't understand why you don't just give it a CSS class of 'required' - that 
way it's not 'fixed' as any particular character, and there are no I18N or 
accessibility issues. 

Seems like the most obvious answer to me (same as when I said this about 4 
weeks ago when this first came up) 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-26 Thread Yevgeniy A. Viktorov


I am using this way:
http://dark-it.blogspot.com/2009/01/symfony-mark-fields-as-required.html
http://dark-it.blogspot.com/2009/01/symfony-mark-fields-as-required-part-2.html

p.s.
Made sfWidgetFormSchemaFormatterDiv and base forms(for propel and
regular forms) for personal needs, then using globally or on per form
basis. Pretty happy with, so far :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-25 Thread avorobiev

Look at 
http://groups.google.com/group/symfony-devs/browse_thread/thread/4c81264521f8bc60

On Feb 24, 2:20 pm, Tomasz Ignatiuk tomek.ignat...@gmail.com wrote:
 On 16 Sty, 13:35, Thomas Dedericks tho...@tequila-studio.com wrote:



  Hi,

  Not tested:

  public function configure() {

          ...

          # add * torequiredfields' labels:
          foreach ($this-widgetSchema as $name = $widget)
          {
                  if (isset($this-validatorSchema[$name])  
  $this-validatorSchema[$name]-hasOption('required')  
  $this-validatorSchema[$name]-getOption('required') == true)
                  {
                          $label = ($widget-getLabel() != null) ? 
  $widget-getLabel() : $name;
                          $widget-setLabel($label.' *');
                  }
          }

  }

  Thomas Dedericks

 Unfortunatelly it doesn't work. But if you do some stuff before and
 with little change...it works :)
 1. Required option is true as default. I don't know why it isn't set
 in widgetSchema. So this won't work: 
 $this-validatorSchema[$name]-hasOption('required')  
 $this-validatorSchema[$name]-getOption

 ('required') == true
 2. If label is set in generator.yml, it isn't  set in widgetSchema, so
 $widget-getLabel() != null is always null You have to set it manually
 in configure()
 3. widgetSchema i a set of objects, not name fields, so you have to
 add this:   foreach ($this-widgetSchema-getFields() as $name =
 $widget)

 So you have to set labels for requried fields in configure() of a form
 and for some fields, like boolean you have to add manually required to
 true, like this: $this-validatorSchema['master'] = new
 sfValidatorBoolean(array('required' = true)); And also change this:
  $this-validatorSchema[$name]-getOption('required') != false).
 required != false

     foreach ($this-widgetSchema-getFields() as $name = $widget)
     {
       if (isset($this-validatorSchema[$name])  
 $this-validatorSchema[$name]-hasOption('required')  $this-
 validatorSchema[$name]-getOption('required') != false)

       {
         $label = ($widget-getLabel() != null) ? $widget-getLabel() :
 $name;
         $widget-setLabel($label.' *');
       }
     }

 All in all it is faster just to add * manually for required fields:
     $this-widgetSchema-setLabels(array(
         'logo' = 'Logo *',
         'name' = 'Name *',
         'master' = 'Master *',
     ));
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-02-24 Thread Tomasz Ignatiuk

On 16 Sty, 13:35, Thomas Dedericks tho...@tequila-studio.com wrote:
 Hi,

 Not tested:

 public function configure() {

         ...

         # add * torequiredfields' labels:
         foreach ($this-widgetSchema as $name = $widget)
         {
                 if (isset($this-validatorSchema[$name])  
 $this-validatorSchema[$name]-hasOption('required')  
 $this-validatorSchema[$name]-getOption('required') == true)
                 {
                         $label = ($widget-getLabel() != null) ? 
 $widget-getLabel() : $name;
                         $widget-setLabel($label.' *');
                 }
         }

 }

 Thomas Dedericks

Unfortunatelly it doesn't work. But if you do some stuff before and
with little change...it works :)
1. Required option is true as default. I don't know why it isn't set
in widgetSchema. So this won't work: $this-validatorSchema[$name]-
hasOption('required')  $this-validatorSchema[$name]-getOption
('required') == true
2. If label is set in generator.yml, it isn't  set in widgetSchema, so
$widget-getLabel() != null is always null You have to set it manually
in configure()
3. widgetSchema i a set of objects, not name fields, so you have to
add this:   foreach ($this-widgetSchema-getFields() as $name =
$widget)

So you have to set labels for requried fields in configure() of a form
and for some fields, like boolean you have to add manually required to
true, like this: $this-validatorSchema['master'] = new
sfValidatorBoolean(array('required' = true)); And also change this:
 $this-validatorSchema[$name]-getOption('required') != false).
required != false

foreach ($this-widgetSchema-getFields() as $name = $widget)
{
  if (isset($this-validatorSchema[$name])  $this-
validatorSchema[$name]-hasOption('required')  $this-
validatorSchema[$name]-getOption('required') != false)
  {
$label = ($widget-getLabel() != null) ? $widget-getLabel() :
$name;
$widget-setLabel($label.' *');
  }
}

All in all it is faster just to add * manually for required fields:
$this-widgetSchema-setLabels(array(
'logo' = 'Logo *',
'name' = 'Name *',
'master' = 'Master *',
));
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-01-16 Thread Lee Bolding

I think the easiest way to achieve this would be if the admin  
generator made the CSS class of the label and input of the required  
column as required - then it would be up to you how you wanted to  
style that (if it all) to express that it was a required field.

I already do a similar thing manually when I build forms - make the  
DIV containing the label and the input selector required - I can  
revisit the CSS at a later date once I know if or how the requirements  
dictate that a required field is communicated to the user

On 16 Jan 2009, at 06:58, CiPheR wrote:


 Does anyone know how to automatically add an indicator (like * or
 required) to the labels of propel generated forms? Considering that
 the form validator already knows which fields are required, it would
 be nice if we can show the user which fields are required right away
 rather than have them submit and the come back with required
 validation messages.

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-01-16 Thread Thomas Dedericks

Hi,

Not tested:

public function configure() {

...

# add * to required fields' labels:
foreach ($this-widgetSchema as $name = $widget)
{
if (isset($this-validatorSchema[$name])  
$this-validatorSchema[$name]-hasOption('required')  
$this-validatorSchema[$name]-getOption('required') == true)
{
$label = ($widget-getLabel() != null) ? 
$widget-getLabel() : $name;
$widget-setLabel($label.' *');
}
}

}

Le jeudi 15 janvier 2009 à 22:58 -0800, CiPheR a écrit :
 Does anyone know how to automatically add an indicator (like * or
 required) to the labels of propel generated forms? Considering that
 the form validator already knows which fields are required, it would
 be nice if we can show the user which fields are required right away
 rather than have them submit and the come back with required
 validation messages.
 
  
 
-- 

Thomas Dedericks

tho...@tequila-studio.com
GSM: +32 (0) 499 23 60 22
http://tequila-studio.com


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: Indicator for required fields

2009-01-16 Thread CiPheR

Lee: Sounds like a great idea, but it still requires manual labor each
time a new Form is generated (I generate mine via Propel). If there
were a way to automate this, it would be the way to go!

Thomas: Thanks. This is a great start. I was looking for something
more along the lines of making a custom decorator to do this without
us having to put this piece of code in each form (I have a lot!). Then
again, I suppose your code could be put into a static function and
invoked as a one-liner from the forms.

I'll take a stab at modifying the decorator and report back.

On Jan 16, 5:35 pm, Thomas Dedericks tho...@tequila-studio.com
wrote:
 Hi,

 Not tested:

 public function configure() {

         ...

         # add * torequiredfields' labels:
         foreach ($this-widgetSchema as $name = $widget)
         {
                 if (isset($this-validatorSchema[$name])  
 $this-validatorSchema[$name]-hasOption('required')  
 $this-validatorSchema[$name]-getOption('required') == true)
                 {
                         $label = ($widget-getLabel() != null) ? 
 $widget-getLabel() : $name;
                         $widget-setLabel($label.' *');
                 }
         }

 }

 Le jeudi 15 janvier 2009 à 22:58 -0800, CiPheR a écrit : Does anyone know 
 how to automatically add anindicator(like * or
  required) to the labels of propel generated forms? Considering that
  the form validator already knows which fields arerequired, it would
  be nice if we can show the user which fields arerequiredright away
  rather than have them submit and the come back with required
  validation messages.

 --

 Thomas Dedericks

 tho...@tequila-studio.com
 GSM: +32 (0) 499 23 60 22http://tequila-studio.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---