-
Notifications
You must be signed in to change notification settings - Fork 435
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
Validating additional fields #9
Comments
Ensure you have added all the fields you want to validate the 'FormFields' attribute. |
Hello, I have this:
So I have 2 problems so far:
|
Not working with jui datepicker. |
I'm unable to reproduce your problem. I need to see the whole view code for analysis :( |
Are you trying it on Yii v 2.0.0 or 2.0.1, maybe it makes difference? if you're on 2.0.1 then I will upload entire code, thanks! |
controllers\EmployeesController.php // here I call actionRegistrationstepone to display the form
models\Employees.php
models\EmployeeQualifications.php
views\employees\registrationstepone.php
|
change
To
|
It is working!!! Sorry, stupid me :) Thank you so much for your time!!! |
Suggestions: Remove the "createMultiple" method of model "Employees" and add in a class that inherits from the \yii\base\Model. Example: Directory: app\base\Model.php <?php
namespace app\base;
use Yii;
use yii\helpers\ArrayHelper;
class Model extends \yii\base\Model
{
public static function createMultiple($modelClass, $multipleModels=null)
{
$model = new $modelClass;
$formName = $model->formName();
$post = Yii::$app->request->post($formName);
$models = [];
$flag = false;
if ($multipleModels !== null && is_array($multipleModels) && !empty($multipleModels)) {
$keys = array_keys(ArrayHelper::map($multipleModels, 'id', 'id'));
$multipleModels = array_combine($keys, $multipleModels);
$flag = true;
}
if ($post && is_array($post)) {
foreach ($post as $i => $item) {
if ($flag) {
if (isset($item['id']) && !empty($item['id']) && isset($multipleModels[$item['id']])) {
$models[] = $multipleModels[$item['id']];
} else {
$models[] = new $modelClass;
}
} else {
$models[] = new $modelClass;
}
}
}
unset($model, $formName, $post);
return $models;
}
} |
I have problem with update in dynamic forms. Please help me...I'm beginner in php public function actionUpdate($id) {
|
customer_id is required field and will fail on line Model.validateMultiple |
Hello,
Very good extension!
I've implemented dynamicform in my project, but looks like it doesn't validate the additional fields created (for example if I click on [+] then try to submit form, only the initial form validates.)
Please advice! Thank you!
The text was updated successfully, but these errors were encountered: