Re: [fw-general] Zend_Form setValue

2009-05-29 Thread samuel verdier

$last_name-setValue('testsamy'); no set the value if the form after
submitting, $last_name = $_POST['last_name'] ($_POST['last_name'] no exist
because last_name is disable) and no testsamy. I want to force this value
because element is disable and when there are errors on the form the element
last_name has a null value.


vince. wrote:
 
 Hi,
 
 I did not understand where you place the null value in the code above, But
 if you do this:
 
  $last_name-setAttrib('disable', null);
 
 this will unset the 'disable' element from the form. It doesn't accept
 null
 values.
 
 On Fri, May 29, 2009 at 1:07 AM, samuel verdier
 samuel.verd...@pyxis.orgwrote:
 

 hello,

 I want to set a value to an element after submitting the form.
 I need it because one element is disable and when there are errors on the
 form the element has a null value.

 this code doesn't works, value = null :

 class App_Form extends Zend_Form
 {
public function init()
{
$last_name = $this-createElement('text', 'last_name')
$last_name-setAttrib('disable', true);
$last_name-setValue('testsamy');

.

return $this;
}
 }

 this code works, value = test:

 class App_Form extends Zend_Form
 {
public function init()
{
$last_name = $this-createElement('text', 'last_name')
$last_name-setAttrib('disable', true);
$last_name-setValue('testsamy');

.

return $this;
}

public function isValid($data)
{
$valid = parent::isValid($data);

$this-getElement('last_name')-setValue('test');

return $valid;
}
 }

 How can i do without overloading the method isValid ?

 Thanks

 --
 View this message in context:
 http://www.nabble.com/Zend_Form-setValue-tp23770977p23770977.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


 
 
 -- 
 Vincent Gabriel.
 Lead Developer, Senior Support.
 Zend Certified Engineer.
 Zend Framework Certified Engineer.
 -- http://www.vadimg.co.il/
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-setValue-tp23770977p23776593.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form setValue

2009-05-29 Thread samuel verdier

i want just force a value of element after submit.
The problem is setValue no setAttrib :

if i have this :

$last_name-setValue('testsamy');
- I change this value last_name in my interface by testsamy2 and i submit
- i recup testsamy2 but i want recup testsamy because i want to force this
value even if it is posted.


vince. wrote:
 
 Hi,
 
 I hope i am understanding you right but if you take a look at
 Zend/Form/Element.php
 
 You will find this:
 
  /**
  * Set element attribute
  *
  * @param  string $name
  * @param  mixed $value
  * @return Zend_Form_Element
  * @throws Zend_Form_Exception for invalid $name values
  */
 public function setAttrib($name, $value)
 {
 $name = (string) $name;
 if ('_' == $name[0]) {
 require_once 'Zend/Form/Exception.php';
 throw new Zend_Form_Exception(sprintf('Invalid attribute %s;
 must not contain a leading underscore', $name));
 }
 
 if (null === $value) {
 unset($this-$name);
 } else {
 $this-$name = $value;
 }
 
 return $this;
 }
 
 so as you can see you cannot set a null value. But what you can do is set
 it
 to an empty string maybe if that's something that you can work with.
 
 On Fri, May 29, 2009 at 12:00 PM, samuel verdier
 samuel.verd...@pyxis.orgwrote:
 

 $last_name-setValue('testsamy'); no set the value if the form after
 submitting, $last_name = $_POST['last_name'] ($_POST['last_name'] no
 exist
 because last_name is disable) and no testsamy. I want to force this value
 because element is disable and when there are errors on the form the
 element
 last_name has a null value.


 vince. wrote:
 
  Hi,
 
  I did not understand where you place the null value in the code above,
 But
  if you do this:
 
   $last_name-setAttrib('disable', null);
 
  this will unset the 'disable' element from the form. It doesn't accept
  null
  values.
 
  On Fri, May 29, 2009 at 1:07 AM, samuel verdier
  samuel.verd...@pyxis.orgwrote:
 
 
  hello,
 
  I want to set a value to an element after submitting the form.
  I need it because one element is disable and when there are errors on
 the
  form the element has a null value.
 
  this code doesn't works, value = null :
 
  class App_Form extends Zend_Form
  {
 public function init()
 {
 $last_name = $this-createElement('text', 'last_name')
 $last_name-setAttrib('disable', true);
 $last_name-setValue('testsamy');
 
 .
 
 return $this;
 }
  }
 
  this code works, value = test:
 
  class App_Form extends Zend_Form
  {
 public function init()
 {
 $last_name = $this-createElement('text', 'last_name')
 $last_name-setAttrib('disable', true);
 $last_name-setValue('testsamy');
 
 .
 
 return $this;
 }
 
 public function isValid($data)
 {
 $valid = parent::isValid($data);
 
 $this-getElement('last_name')-setValue('test');
 
 return $valid;
 }
  }
 
  How can i do without overloading the method isValid ?
 
  Thanks
 
  --
  View this message in context:
  http://www.nabble.com/Zend_Form-setValue-tp23770977p23770977.html
  Sent from the Zend Framework mailing list archive at Nabble.com.
 
 
 
 
  --
  Vincent Gabriel.
  Lead Developer, Senior Support.
  Zend Certified Engineer.
  Zend Framework Certified Engineer.
  -- http://www.vadimg.co.il/
 
 

 --
 View this message in context:
 http://www.nabble.com/Zend_Form-setValue-tp23770977p23776593.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


 
 
 -- 
 Vincent Gabriel.
 Lead Developer, Senior Support.
 Zend Certified Engineer.
 Zend Framework Certified Engineer.
 -- http://www.vadimg.co.il/
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-setValue-tp23770977p23776829.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form setValue

2009-05-29 Thread samuel verdier

No because i want to display initial value of a disable element after submit
when i have an error.
The hidden element no resolves the problem.

I have a select with a value selected but this select is disable.
when i submit form with a error, i want to redisplay the form and select
element display with a initial value selected.


Kyohere Luke wrote:
 
 Might using a hidden field do what u want?
 
 On Fri, May 29, 2009 at 12:20 PM, samuel verdier
 samuel.verd...@pyxis.orgwrote:
 

 i want just force a value of element after submit.
 The problem is setValue no setAttrib :

 if i have this :

 $last_name-setValue('testsamy');
 - I change this value last_name in my interface by testsamy2 and i
 submit
 - i recup testsamy2 but i want recup testsamy because i want to force
 this
 value even if it is posted.


 vince. wrote:
 
  Hi,
 
  I hope i am understanding you right but if you take a look at
  Zend/Form/Element.php
 
  You will find this:
 
   /**
   * Set element attribute
   *
   * @param  string $name
   * @param  mixed $value
   * @return Zend_Form_Element
   * @throws Zend_Form_Exception for invalid $name values
   */
  public function setAttrib($name, $value)
  {
  $name = (string) $name;
  if ('_' == $name[0]) {
  require_once 'Zend/Form/Exception.php';
  throw new Zend_Form_Exception(sprintf('Invalid attribute
 %s;
  must not contain a leading underscore', $name));
  }
 
  if (null === $value) {
  unset($this-$name);
  } else {
  $this-$name = $value;
  }
 
  return $this;
  }
 
  so as you can see you cannot set a null value. But what you can do is
 set
  it
  to an empty string maybe if that's something that you can work with.
 
  On Fri, May 29, 2009 at 12:00 PM, samuel verdier
  samuel.verd...@pyxis.orgwrote:
 
 
  $last_name-setValue('testsamy'); no set the value if the form after
  submitting, $last_name = $_POST['last_name'] ($_POST['last_name'] no
  exist
  because last_name is disable) and no testsamy. I want to force this
 value
  because element is disable and when there are errors on the form the
  element
  last_name has a null value.
 
 
  vince. wrote:
  
   Hi,
  
   I did not understand where you place the null value in the code
 above,
  But
   if you do this:
  
$last_name-setAttrib('disable', null);
  
   this will unset the 'disable' element from the form. It doesn't
 accept
   null
   values.
  
   On Fri, May 29, 2009 at 1:07 AM, samuel verdier
   samuel.verd...@pyxis.orgwrote:
  
  
   hello,
  
   I want to set a value to an element after submitting the form.
   I need it because one element is disable and when there are errors
 on
  the
   form the element has a null value.
  
   this code doesn't works, value = null :
  
   class App_Form extends Zend_Form
   {
  public function init()
  {
  $last_name = $this-createElement('text', 'last_name')
  $last_name-setAttrib('disable', true);
  $last_name-setValue('testsamy');
  
  .
  
  return $this;
  }
   }
  
   this code works, value = test:
  
   class App_Form extends Zend_Form
   {
  public function init()
  {
  $last_name = $this-createElement('text', 'last_name')
  $last_name-setAttrib('disable', true);
  $last_name-setValue('testsamy');
  
  .
  
  return $this;
  }
  
  public function isValid($data)
  {
  $valid = parent::isValid($data);
  
  $this-getElement('last_name')-setValue('test');
  
  return $valid;
  }
   }
  
   How can i do without overloading the method isValid ?
  
   Thanks
  
   --
   View this message in context:
   http://www.nabble.com/Zend_Form-setValue-tp23770977p23770977.html
   Sent from the Zend Framework mailing list archive at Nabble.com.
  
  
  
  
   --
   Vincent Gabriel.
   Lead Developer, Senior Support.
   Zend Certified Engineer.
   Zend Framework Certified Engineer.
   -- http://www.vadimg.co.il/
  
  
 
  --
  View this message in context:
  http://www.nabble.com/Zend_Form-setValue-tp23770977p23776593.html
  Sent from the Zend Framework mailing list archive at Nabble.com.
 
 
 
 
  --
  Vincent Gabriel.
  Lead Developer, Senior Support.
  Zend Certified Engineer.
  Zend Framework Certified Engineer.
  -- http://www.vadimg.co.il/
 
 

 --
 View this message in context:
 http://www.nabble.com/Zend_Form-setValue-tp23770977p23776829.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-setValue-tp23770977p23779906.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_Form setValue

2009-05-28 Thread samuel verdier

hello,

I want to set a value to an element after submitting the form.
I need it because one element is disable and when there are errors on the
form the element has a null value.

this code doesn't works, value = null :

class App_Form extends Zend_Form
{
public function init()
{
$last_name = $this-createElement('text', 'last_name')
$last_name-setAttrib('disable', true);
$last_name-setValue('testsamy');

.

return $this;
}
}

this code works, value = test:

class App_Form extends Zend_Form
{
public function init()
{
$last_name = $this-createElement('text', 'last_name')
$last_name-setAttrib('disable', true);
$last_name-setValue('testsamy');

.

return $this;
}

public function isValid($data)
{
$valid = parent::isValid($data);

$this-getElement('last_name')-setValue('test');

return $valid;
}
}

How can i do without overloading the method isValid ?

Thanks

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-setValue-tp23770977p23770977.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend Form and addError

2008-08-05 Thread Samuel Verdier
Hi,

Adding an error on an element 'multiCheckbox' does not work :

$droitModel = new Droit();
$tabDroits = $droitModel-getDroitsModule($this-initData-module);
$droits = $this-createElement('multiCheckbox', 'droits');
$droits-setMultiOptions($tabDroits)
   -setLabel($this-_translateController-_('type_droits'))
   -setValue($this-initData-droits)
   -setDecorators($this-_elementDecorators)
   -setRequired(true);
    
$droits-addError('test');

Error : Notice: Array to string conversion in
/usr/share/php/Zend/Form/Element.php on line 2063.
Zend_Form_Element ligne 2063 : $messages[$key] = str_replace('%value%',
$value, $message);
$value is a array in the case of an element with a multiOptions.

Cordialement,

Samuel verdier – Directeur technique
[EMAIL PROTECTED]



[fw-general] zend form adderror and isvalid

2008-08-05 Thread Samuel Verdier
Hi,

In use addError('test');

And : $form-isValid($formData); retour true.

Is this normal?

So I do :

if (count($form-getMessages()) == 0  $form-isValid($formData)) {
echo 'OK';
}



Cordialement,

Samuel verdier - Directeur technique
[EMAIL PROTECTED]



RE: [fw-general] zend form adderror and isvalid

2008-08-05 Thread Samuel Verdier

and when I do this :

if (count($form-getMessages()) == 0  $form-isValid($formData)) {
echo 'OK';
}

if there are errors added by addError() the others errors from validator
form-isValid($formData) are not displayed

Cordialement,


Samuel verdier – Directeur technique
[EMAIL PROTECTED]


-Message d'origine-
De : Samuel Verdier [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 5 août 2008 15:43
À : fw-general@lists.zend.com
Objet : [fw-general] zend form adderror and isvalid

Hi,

In use addError('test');

And : $form-isValid($formData); retour true.

Is this normal?

So I do :

if (count($form-getMessages()) == 0  $form-isValid($formData)) {
echo 'OK';
}



Cordialement,

Samuel verdier - Directeur technique
[EMAIL PROTECTED]





RE: [fw-general] zend form adderror and isvalid

2008-08-05 Thread Samuel Verdier

I found the same problem but
no answer : 

http://www.nabble.com/Zend-Form-isValid%28%29---custom-errors-td18729453.htm
l#a18729453


I found the same problem
Cordialement,


Samuel verdier – Directeur technique
[EMAIL PROTECTED]


-Message d'origine-
De : Samuel Verdier [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 5 août 2008 15:47
À : fw-general@lists.zend.com
Objet : RE: [fw-general] zend form adderror and isvalid


and when I do this :

if (count($form-getMessages()) == 0  $form-isValid($formData)) {
echo 'OK';
}

if there are errors added by addError() the others errors from validator
form-isValid($formData) are not displayed

Cordialement,


Samuel verdier – Directeur technique
[EMAIL PROTECTED]


-Message d'origine-
De : Samuel Verdier [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 5 août 2008 15:43
À : fw-general@lists.zend.com
Objet : [fw-general] zend form adderror and isvalid

Hi,

In use addError('test');

And : $form-isValid($formData); retour true.

Is this normal?

So I do :

if (count($form-getMessages()) == 0  $form-isValid($formData)) {
echo 'OK';
}



Cordialement,

Samuel verdier - Directeur technique
[EMAIL PROTECTED]







[fw-general] zend form

2008-08-04 Thread samuel verdier

Hi,

I make a zend_element_date but I'd like to know if it is seen from the point 
of conception.

In my element date I have added a parameter specific:
setCalendar true or false for a display jscalendar right zend text element.
that you think, is this the right way to add specific parameters?
I did not deliberately added parameters in these options as they appear in 
the html code.


in my controller :

   $date_publication = $this-createElement('date', 
'date_publication');

   
$date_publication-setLabel($this-_translateController-_('date_publication'))
-setDescription('Format : ' . $format['short'] . '')
-addValidator($validatorDate)
-setRequired(true)
-setCalendar(true)
-setValue($this-initData-date_publication)

-

class Pyxis_Form_Element_Date extends Zend_Form_Element_Xhtml
{
public $helper = 'formElementDate';
protected $_spec = array ('calendar' = false);
public function setSpec($spec)
{
$this-_spec = $spec;
return $this;
}
public function getSpec()
{
return $this-_spec;
}
public function setCalendar($bool)
{
$this-_spec['calendar'] = (boolean) $bool;
return $this;
}
public function setHour($bool)
{
$this-_spec['withHour'] = (boolean) $bool;
return $this;
}
}

-

class Zend_View_Helper_FormElementDate extends Zend_View_Helper_FormElement
{
public function formElementDate($name, $value = null, $attribs = null, 
$options = null, $spec = null)

{
/*$filterDbToDate = new Pyxis_Filter_DbToDate();
$value = $filterDbToDate-filter($value);*/
$xhtml = $this-view-formText($name, $value, array_merge($attribs, 
array('maxlength' = 10)));

if (!empty($spec['calendar'])) {
$xhtml .= '
a href=javascript:void(0) id=calendarLink_' . $name . 'img src=' . 
$this-view-baseUrl . '/images/calendar.png alt= id=calendar_' . $name 
. ' //a

script type=text/javascript
//![CDATA[
Calendar.setup({
inputField : '. $name . ', // id of the input field
ifFormat : %d/%m/%Y, // format of the input field
showsTime : true, // will display a time selector
button : calendar_' . $name . ', // trigger for the calendar (button ID)
singleClick : true, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year 
as default)

});
//]]
/script';
}
return $xhtml;
}
}

thanks,

samuel 



[fw-general] controler + throw exception

2008-08-01 Thread Samuel Verdier
Hi,

I would like display an exception in javascript.
If an exception is lift in the controller, i want stay in the current page
and display the exception in javascript alert.
How can I do that ?


Samuel verdier – Directeur technique
[EMAIL PROTECTED]

www.pyxis.org
150, allée du Pays d’Oc, 34080 Montpellier - Tél. 04 67 10 77 88 - Fax
04 67 10 77 87
41, rue Meslay, 75003 Paris - Tél. 01 42 85 55 04  - Fax 01 42 85 56 30




RE: [fw-general] zend translate and zend form

2008-07-31 Thread Samuel Verdier
I have two adapters one for all errors and one by module because my
application is modular.
In every module the file language is include in a subdirectory.
The file of error is for all application

Cordialement,


Samuel verdier – Directeur technique
[EMAIL PROTECTED]


-Message d'origine-
De : Thomas Weidner [mailto:[EMAIL PROTECTED] 
Envoyé : jeudi 31 juillet 2008 00:13
À : samuel verdier; fw-general@lists.zend.com
Objet : Re: [fw-general] zend translate and zend form

Why do you seperate the translation adapters ?
Simply use one adapter where you add the files you want to translate. Use 
addTranslation instead of multiple instances. Add only the modules you need.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - 
From: samuel verdier [EMAIL PROTECTED]
To: fw-general@lists.zend.com
Sent: Wednesday, July 30, 2008 11:47 PM
Subject: [fw-general] zend translate and zend form


 Hi All,

 I have multi file for translate (tmx) and i want to merge it

 One file for global error form, others by controler

 $this-translateFormError = new Zend_Translate('tmx', TMX_DIR . 
 '/form_errors.tmx', $this-lang);
 $translateController = new Zend_Translate('tmx', MODULES_DIR . '/' . 
 $module . '/languages/' . $module . '_' . $controller . '.tmx', 
 $this-lang);
 $this-form-setTranslator($this-translateFormError);
 $this-form-setTranslator($this-translateController);

 How can i solve my probleme with the zend 1.6RC1 ?

 It is possible to do this for futur version :
 $this-form-setTranslators(array($this-translateFormError, 
 $this-translateController));

 Samuel 





[fw-general] Zend_Form populate and getValue

2008-07-31 Thread Samuel Verdier
Hi,

How can I recupe values $formData with populate function (  
without using addValue) ?

$form-populate($formData);

$titre = $this-createElement('text', 'titre');
$titre-setLabel('title');

echo $titre-getValue(); /*display nothing*/

But if I do :

$titre = $this-createElement('text', 'titre');
$titre-setLabel('title')
-addValue('test');

echo $titre-getValue(); /*display the title : test*/
 

Cordialement,

Samuel verdier - Directeur technique
[EMAIL PROTECTED]



Re: [fw-general] zend translate and zend form

2008-07-31 Thread samuel verdier
Ok but i think that do two different functions for tranlate label and error 
would be nice :


$this-form-setLabelTranslators($this-translateFormLabel);
$this-form-setErrorTranslators($this-translateFormError);

no ?


- Original Message - 
From: Thomas Weidner [EMAIL PROTECTED]

To: Samuel Verdier [EMAIL PROTECTED]; fw-general@lists.zend.com
Sent: Thursday, July 31, 2008 1:41 PM
Subject: Re: [fw-general] zend translate and zend form



But this can not work...
I will give you an example:

Let's say you have the source 'Hello'.
You have translated it in both instances but you transated it differently 
in both of them.


How should Zend_Form know which instance to use ? Which is the proper one 
for this situation ?
As I said the only working way is to use one instance and add the sources 
when they are needed.

There is no need for multiple instances at all.
Just add the sources before you want to use them.

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - 
From: Samuel Verdier [EMAIL PROTECTED]

To: fw-general@lists.zend.com
Sent: Thursday, July 31, 2008 12:47 PM
Subject: RE: [fw-general] zend translate and zend form


I have two adapters one for all errors and one by module because my
application is modular.
In every module the file language is include in a subdirectory.
The file of error is for all application

Cordialement,


Samuel verdier - Directeur technique
[EMAIL PROTECTED]


-Message d'origine-
De : Thomas Weidner [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 31 juillet 2008 00:13
À : samuel verdier; fw-general@lists.zend.com
Objet : Re: [fw-general] zend translate and zend form

Why do you seperate the translation adapters ?
Simply use one adapter where you add the files you want to translate. Use
addTranslation instead of multiple instances. Add only the modules you 
need.


Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - 
From: samuel verdier [EMAIL PROTECTED]

To: fw-general@lists.zend.com
Sent: Wednesday, July 30, 2008 11:47 PM
Subject: [fw-general] zend translate and zend form



Hi All,

I have multi file for translate (tmx) and i want to merge it

One file for global error form, others by controler

$this-translateFormError = new Zend_Translate('tmx', TMX_DIR .
'/form_errors.tmx', $this-lang);
$translateController = new Zend_Translate('tmx', MODULES_DIR . '/' .
$module . '/languages/' . $module . '_' . $controller . '.tmx',
$this-lang);
$this-form-setTranslator($this-translateFormError);
$this-form-setTranslator($this-translateController);

How can i solve my probleme with the zend 1.6RC1 ?

It is possible to do this for futur version :
$this-form-setTranslators(array($this-translateFormError,
$this-translateController));

Samuel









[fw-general] paginator

2008-07-27 Thread samuel verdier

Hi,

i am french... so my language is not good...

I would like to receive an object and not a array with : myItems = 
$paginator-getCurrentItems();


it would be possible to have a object like Zend_Db::FETCH_OBJ when i use 
DbSelect adaptater of paginator ?


thanks