cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] More consistent naming of Phalcon::Tag's

Open rvanderfeer opened this issue 13 years ago • 9 comments

IMHO Phalcon::Tag's are not named consistently. HTML form input fields are currently mostly suffixed with 'Field', e.g. textField, hiddenField. 'Field' is not really an obvious name though as HTML provides us with the 'input' tag with a 'type'. I would suggest inputText or something similar to more closely match the HTML vocabulary so it is easier to learn and remember.

Other examples of inconsistencies;

  • checkField; the HTML type is 'checkbox', not 'check', suggest inputCheckbox
  • submitButton; it generates an input with type submit, not a button; suggest inputSubmit
  • textArea; the HTML tag is 'textarea', not camel-cased

Missing input types (AFAICT);

  • input type button
  • input type image

Also; HTML5 provides us with many new input types (search, date, number etc.) which are currently not supported by Phalcon Tag's - granted not all browsers currently support these fields, but perhaps this raises the question if Phalcon::Tag / Volt functions should provide full coverage of all HTML tags.

rvanderfeer avatar Feb 11 '13 17:02 rvanderfeer

+1, if those items could be standartized more - it would be very nice. All applications my team is working on are based on HTML5 only, and we have to add our functionality instead of using Phalcon's native.

In addition for those suggestion - Forms/Form elements components are very important (that could be based on Phalcon's Tag). Currently we have to use our solution.. and we're waiting for this feature very.. very much :)

alvassin avatar Feb 11 '13 17:02 alvassin

Hi, thanks for your recommendations, but as you may know, we can't change the current names right now because that would break the current applications and we don't want that. This could be done in a future release Phalcon 2.0 or something.

Maybe the missing helpers could be added if they add some value to the HTML generation.

ghost avatar Feb 11 '13 17:02 ghost

This will be introduced definitely at a later version of Phalcon most likely around 2.0 as stated.

We need to think about this through and how it will tie with the upcoming forms builder so that we keep components as efficient and loosely coupled as possible without impacting performance.

Thank you for your suggestions!!

niden avatar Feb 11 '13 18:02 niden

Personally I feel this component needs rework sooner rather than later, for the exact same reason phalcon poses; why wait until more apps are affected? At least at this point in time PhalconPHP has not yet reached v1.0 - so I would expect the API to change as the framework develops.

Please at least consider upgrading the documentation to provide more examples, like setting the active element in a select box or checking a checkbox, perhaps this would partially solve my issue.

Also see #422

rvanderfeer avatar Feb 11 '13 22:02 rvanderfeer

I understand that better names is something positive, but a couple of inconsistent names is not a reason to break the current applications, from your point of view this is a priority but I'm not sure if this is a priority for the general community, maybe the names aren't perfect but sufficiently understandable, this is not a functional problem.

You can always create a class providing the names you consider better, mapping to the inconsistent ones.

ghost avatar Feb 11 '13 23:02 ghost

You can do in version 1.0 aliases of these methods, as suggested rvanderfeer. Old names mark as deprecated, and in version 2.0 remove them completely.

nikolasha avatar Feb 13 '13 12:02 nikolasha

@nikolasha +1

alvassin avatar Feb 13 '13 14:02 alvassin

We will most likely use that approach.

Like I wrote, we need to think of the Tag element in two scopes

  1. As a standalone component offering the current (and more) functionality
  2. As a helper component to the forms builder

Most likely we will create a brand new component that would do this work and slowly start deprecating the Tag one - maybe v2 or v3.

We still haven't decided on this but the minute we do we will share it with the community :)

The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.

On Wed, Feb 13, 2013 at 9:34 AM, Alexander [email protected] wrote:

@nikolasha https://github.com/nikolasha +1

— Reply to this email directly or view it on GitHubhttps://github.com/phalcon/cphalcon/issues/420#issuecomment-13496202.

niden avatar Feb 13 '13 14:02 niden

We have addressed this by using a generic HTML helper.

This allows you to create any element (even HTML5) ones without any naming convention worries or breaking backwards compatibility.

http://docs.phalconphp.com/en/1.1.0/reference/tags.html#html5-elements-generic-html-helper

niden avatar May 02 '13 18:05 niden