This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jamiegrand
jamiegrand

Cant get form validation to work not sure what I am doing wrong. Any suggestions. if i submit the form without a customer I get a database error message as this field cant be null.

the fields.yamil

customer: label: 'grand.stripe::lang.customer.id' nameFrom: customer descriptionFrom: description emptyOption: select span: auto required: 1 type: relation comment: 'grand.stripe::lang.customer.comment'

the model `

use \October\Rain\Database\Traits\Validation;

 /*
 * Validation
 */
public $rules = [
     'customer'    => 'required'
];

public $customMessages = [
    'customer.required' => 'A customer is required.',
];

/**
 * @var string The database table used by the model.
 */
public $table = 'grand_stripe_subscription';

/**
 * @var array Relations
 */
public $belongsTo = [
    'customer' => ['Grand\Stripe\Models\Customer','table' => 'grand_stripe_customer', 'scope' => 'isActive'],        
    'coupon' => ['Grand\Stripe\Models\Coupon'],
    'plan' => ['Grand\Stripe\Models\Plan']  
];`
jamiegrand
jamiegrand

I was missing... `

public function formBeforeSave($model)
{
     $model->validate();

} 

`

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.