Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.5.0a \Phalcon\Tag inconsistency #31

Closed
niden opened this issue Jul 23, 2012 · 7 comments
Closed

0.5.0a \Phalcon\Tag inconsistency #31

niden opened this issue Jul 23, 2012 · 7 comments
Labels
bug A bug report status: medium Medium

Comments

@niden
Copy link
Sponsor Member

niden commented Jul 23, 2012

I think that \Phalcon\Tag is not generating content correctly.

The syntax is: \Phalcon\Tag(array(name, <option => value>));

$options  = array(
    'myname',
    'id'    => 'myid',
    'class' => 'myclass',
    'size'  => '10',
);
$expected = '<input type="text" value="" id="myid" class="myclass" size="10" name="myname"  />';
$actual   = \Phalcon\Tag::textField($options);

$this->assertEquals($expected, $actual, 'textField with id in parameters does not return proper html element');

The above produces:

Expected :<input type="text" value="" id="myid" class="myclass" size="10" name="myname"  />
Actual   :<input type="text" id="myname" value="" id="myid" class="myclass" size="10" name="myname"  />

As you can see the above does set the id="myid" but it also sets id="myname".

Expected behavior: If id is in the list of parameters, it should override the preset one.

$options  = array(
    'myname',
    'name'  => 'othername',
    'id'    => 'myid',
    'class' => 'myclass',
    'size'  => '10',
);
$expected = '<input type="text" value="" name="othername" id="myid" class="myclass" size="10"  />';
$actual   = \Phalcon\Tag::textField($options);

$this->assertEquals($expected, $actual, 'textField with name and id in parameters does not return proper html element');

The above produces:

Expected :<input type="text" value="" name="othername" id="myid" class="myclass" size="10"  />
Actual   :<input type="text" id="myname" value="" name="othername" id="myid" class="myclass" size="10"  />

As you can see this one also produces a duplicate id but correctly changes the 'name' attribute is passed in the parameters.

@niden
Copy link
Sponsor Member Author

niden commented Jul 23, 2012

Same thing happens with textArea, passwordField, hiddenField, textField etc.

Also one minor thing I noticed is that the attributes do not appear in constant order. This is very minor and has no effect in the operation of the component or the generation of the HTML but it is a nice to have.

For instance I have seen:

<element type=X id="" attribute="" ... name="" />

but also

<element type=X id="" name=""  attribute="" ... />

Again it would be nice if the order of the attributes remains constant. A suggestion is:

<element type="" name="" id="" value="" attribute="" .... />

(that is of course if id and/or value are present.

@niden
Copy link
Sponsor Member Author

niden commented Jul 23, 2012

Also \Phalcon\Tag::image does not close the tag as XHTML. This is a minor one but it helps being consistent.

\Phalcon\Tag::image('img/hello.gif') creates:

<img src='/img/hello.gif'>

(with a PHP_EOL at the end.

It should be:

<img src='/img/hello.gif' />

(with a PHP_EOL at the end).

I am not sure why a PHP_EOL is needed at the end of the output. I would personally remove it.

@niden
Copy link
Sponsor Member Author

niden commented Jul 23, 2012

resetInput()

I have the following code:

use \Phalcon\Tag as Tg;

$options  = 'some_field_name';
$expected = '<input type="text" id="some_field_name" value="Wall-E" name="some_field_name"  />';
Tg::setDefault('some_field_name', 'Wall-E');
$actual   = Tg::textField($options);

$this->assertEquals($expected, $actual, 'resetInput before does not contains a value');

Tg::resetInput();
$expected = '<input type="text" id="some_field_name" value="" name="some_field_name"  />';
$this->assertEquals($expected, $actual, 'resetInput after contains a value');

The results are:

Expected :<input type="text" id="some_field_name" value="" name="some_field_name"  />
Actual   :<input type="text" id="some_field_name" value="Wall-E" name="some_field_name"  />

So unless I got this wrong, resetInput() does not reset the setDefault() earlier.

@ghost ghost assigned phalcon Jul 24, 2012
@phalcon
Copy link
Collaborator

phalcon commented Jul 24, 2012

Thanks, now these issues are part of the next alpha.

@niden
Copy link
Sponsor Member Author

niden commented Jul 24, 2012

Thanks!. I might add a couple more (if I find any) regarding Tag. Still working on the list of methods.

@phalcon
Copy link
Collaborator

phalcon commented Aug 17, 2012

Hi Nikolaos, these problems are now fixed in 0.5.0a3, thanks

@phalcon phalcon closed this as completed Aug 17, 2012
@niden
Copy link
Sponsor Member Author

niden commented Aug 17, 2012

Awesome!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

1 participant