Yii Framework Forum: Forms etc. close tag - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Forms etc. close tag Rate Topic: -----

#1 User is offline   ekerazha 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 524
  • Joined: 10-October 08
  • Location:European Union

Posted 10 November 2008 - 07:16 PM

Here http://www.yiiframew.../api/CHtml#form I read

Quote

Generates a form tag. Note, only the open tag is generated. A close tag should be placed manually at the end of the form.


This is not very nice also if you think that an editor with syntax checking could detect than you close a tag ( </form> ) but you didn't open it (because it is opened calling the PHP method). So it seems like this is not the most coherent behaviour.

Is there something we could do here to make this thing nicer?

Maybe a closeForm() method or a generic closeTag('form'), I don't know...

What do you think?
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,857
  • Joined: 04-October 08
  • Location:DC, USA

Posted 10 November 2008 - 08:30 PM

While your point is true, I found other frameworks are doing the same thing as Yii. Creating a function like closeTag()/closeForm() also brings us more trouble than benefit.
0

#3 User is offline   sebas 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 494
  • Joined: 28-October 08
  • Location:Buenos Aires, Argentina

Posted 11 November 2008 - 11:58 AM

But it's good that we can check if we open more than one form inside another or something like this... This could be a nice trick to form open/close check.
0

#4 User is offline   DarkNSF 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 287
  • Joined: 12-November 08
  • Location:Palm Bay, Florida

Posted 13 November 2008 - 09:40 PM

Here are my thoughts, feel free to shoot them down. How about create a form object and add to it and then add a function on it to return the html? (please excuse my makeshift syntax for explaining haha)


CForm theform = new CForm(action, method, etc, etc);
theForm.addItem(new FormItem());
theForm.addItem(new FormItem());
theForm.addItem(new FormItem());
echo theForm->getFormHtml();


when getFormHtml() is called it would look in to an internal array of FormItems and begin building the html. one step further... the FormItem could have it's own getHtml().


public function getFormHtml()
{
  String html;
  foreach(FormItem item: FormItemArray)
  {
    html .= item.getHtml();
  }
  return html;
}



which would return your entire form..


<form>
  <input...>
</form>


Quote

While your point is true, I found other frameworks are doing the same thing as Yii. Creating a function like closeTag()/closeForm() also brings us more trouble than benefit.


Yes, there would be no added benefit. The developer would still need to remember to call that method, and calling a method will add some overhead.
0

#5 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,857
  • Joined: 04-October 08
  • Location:DC, USA

Posted 13 November 2008 - 09:52 PM

For static forms (used in most cases), using CForm is a bit too restrict as a form is often composed by many complex design elements. It is less intuitive to designers.

That said, using CForm is good for building dynamic forms (form input fields are determined according to some data). So we may consider implementing such feature in future (AFAIK, Symfony has this).
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users