Coder Social home page Coder Social logo

Comments (6)

rustamwin avatar rustamwin commented on June 1, 2024 1

@terabytesoftw I meant this test:

Yiisoft\Form\Tests\Widget\NoExistTest::test Undefined property: Yiisoft\Form\Tests\Stub\PersonalForm::$undefined_form_attribute

as you said above.

from form.

terabytesoftw avatar terabytesoftw commented on June 1, 2024

Of course you are just creating the object, you are not rendering it.

(new TextInput)->config($data, 'undefined_form_attribute')->run();

TextInput::widget()->config($data, 'undefined_form_attribute')->run();

<?= (new TextInput)->config($data, 'undefined_form_attribute') ?>

<?= TextInput::widget()->config($data, 'undefined_form_attribute') ?>
  1. Yiisoft\Form\Tests\Widget\NoExistTest::test Undefined property: Yiisoft\Form\Tests\Stub\PersonalForm::$undefined_form_attribute

from form.

iamsaint avatar iamsaint commented on June 1, 2024

Please reopen issue. In your described cases widget still no throws exception for undefined field

class LoginForm extends FormModel {
    private ?string $login;
    private ?string $password;
    /* ...  */
}
echo (new TextInput)->config($formModel, 'login')->run();
echo (new PasswordInput)->config($formModel, 'password')->run();
echo (new TextInput)->config($formModel, 'undefined_form_attribute')->run();

in html i got this

<input type="text" id="login" name="login">
<input type="password" id="password" name="password">
<input type="text" id="undefined_form_attribute" name="undefined_form_attribute">

from form.

rustamwin avatar rustamwin commented on June 1, 2024

@terabytesoftw tests do not exist for undefined form field

from form.

terabytesoftw avatar terabytesoftw commented on June 1, 2024

Please reopen issue. In your described cases widget still no throws exception for undefined field

class LoginForm extends FormModel {
    private ?string $login;
    private ?string $password;
    /* ...  */
}
echo (new TextInput)->config($formModel, 'login')->run();
echo (new PasswordInput)->config($formModel, 'password')->run();
echo (new TextInput)->config($formModel, 'undefined_form_attribute')->run();

in html i got this

<input type="text" id="login" name="login">
<input type="password" id="password" name="password">
<input type="text" id="undefined_form_attribute" name="undefined_form_attribute">

You can put all the code to reproduce the error clearly you must have some problem in your php configuration, I already added the exception but it is redundant all the widgets use getAttributeValue(), and when looking to return the value of the property it should throw the error because it does not exists.

I still wonder why it does not generate the error, if it is tested.

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/src/Widget/TextInput.php#L24

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/src/Widget/Input.php#L42

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/src/Widget/Input.php#L229

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/src/Helper/HtmlForm.php#L40

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/src/FormModel.php#L289

@rustamwin We must verify well, I think it is not a bug.

from form.

terabytesoftw avatar terabytesoftw commented on June 1, 2024

@terabytesoftw tests do not exist for undefined form field

https://github.com/yiisoft/yii-form/blob/b18bc146c897145542a4dbd94bb2e8f20bb447d3/tests/FormModelTest.php#L31

I don't need to test the widget because it is clearly tested in the FormModel.

Any object that calls a property that doesn't exist php will return an error.

from form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.