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

[NFR] Phalcon\Forms\Form::label() extra param #1029

Closed
anggiaj opened this issue Aug 8, 2013 · 5 comments
Closed

[NFR] Phalcon\Forms\Form::label() extra param #1029

anggiaj opened this issue Aug 8, 2013 · 5 comments

Comments

@anggiaj
Copy link

anggiaj commented Aug 8, 2013

\Phalcon\Forms\Form::label(string $name) according to the doc, "Generate the label of a element added to the form including HTML"

I think it's need to have extra $attributes param, because it's mean to render HTML, so it will be consistent with render method.

ex:

$form->label('name', array('class' => 'form-control'));

but right now, what i have to do...

<label for="name" class="form-control"><?=$form->getLabel('name'); ?></label>

CMIIW

@dreamsxin
Copy link
Contributor

Test it, Indeed return label tag:

<?php
use Phalcon\Forms\Form,
    Phalcon\Forms\Element\Text,
    Phalcon\Forms\Element\Select;

$form = new Form();
$form->add(new Text("telephone", array(
    'maxlength' => 30,
    'placeholder' => 'Type your name'
)));

$text = $form->get('telephone');

echo $form->label('telephone');
echo PHP_EOL;
echo $form->getLabel('telephone');
echo PHP_EOL;
echo $text->getName();

output:

<label for="telephone">telephone</label>
telephone
telephone

ovr added a commit to ovr/cphalcon that referenced this issue Sep 8, 2013
@phalcon
Copy link
Collaborator

phalcon commented Sep 25, 2013

This is implemented in 1.3.0

@PersyJack
Copy link

Using this, how does one generate a label as
<label for="telephone">Enter your number:</label>
instead of
<label for="telephone">telephone</label>

@dreamsxin
Copy link
Contributor

@PersyJack

echo $text->setLabel('Enter your number:');

@PersyJack
Copy link

@dreamsxin Thank you, I was studying Vokuro and I tried adding 'text' => 'Enter phone number' to login controller where it has

$email = new Text('email', array(
            'placeholder' => 'Email'
        ));

but that just added a text attribute to the input.
After your reply, I found that it was setup up that way in signup controller.
Thank you again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants