\User_Form_Account

Update user info

از این کلاس برای اعتبار سنجی فرم‌ها و تولید داده‌های معادل استفاده می‌شود. از این کلاس همانند مدل داده‌ای استفاده می‌شود. با استفاده از این کلاس می‌توان داده‌های اضافه ارسال شده را حذف کرده و در صورت نا مناسب بودن پارامترهای دریافتی خطای مناسب ایجاد کرد.

Summary

Methods
Properties
Constants
__construct()
initFields()
addPrefix()
isValid()
clean()
failed()
initial()
render_top_errors()
get_top_errors()
field()
current()
key()
next()
rewind()
valid()
offsetUnset()
offsetSet()
offsetGet()
offsetExists()
save()
update()
$fields
$prefix
$id_fields
$data
$cleaned_data
$errors
$is_bound
$f
$label_suffix
$user_data
No constants found
No protected methods found
$is_valid
N/A
No private methods found
No private properties found
N/A

Properties

$fields

$fields : 

The fields of the form.

They are the fully populated Pluf_FormField* of the form. You define them in the initFields method.

Type

$prefix

$prefix : 

Prefix for the names of the fields.

Type

$id_fields

$id_fields : 

Type

$data

$data : 

Type

$cleaned_data

$cleaned_data : 

Type

$errors

$errors : 

Type

$is_bound

$is_bound : 

Type

$f

$f : 

Type

$label_suffix

$label_suffix : 

Type

$user_data

$user_data : 

Type

$is_valid

$is_valid : 

Type

Methods

__construct()

__construct(  $data = null,   $extra = array(),   $label_suffix = null) 

Parameters

$data
$extra
$label_suffix

initFields()

initFields(  $extra = array()) 

مقدار دهی فیلدها.

Parameters

$extra

addPrefix()

addPrefix(  $field_name) : string

Add the prefix to the form names.

Parameters

$field_name

Returns

string —

Field name or field name with form prefix.

isValid()

isValid() : array

Check if the form is valid.

It is also encoding the data in the form to be then saved. It is very simple as it leaves the work to the field. It means that you can easily extend this form class to have a more complex validation procedure like checking if a field is equals to another in the form (like for password confirmation) etc.

Returns

array —

Array of errors

clean()

clean() : array

فرآیند اصلی پاک کردن داده‌ها در فرم

با استفاده از این فراخوانی می‌توان تمام پارامترهای یک فرم را بررسی کرد. تفاوت اصلی این بررسی با سایر موارد این است که در اینجا تمام پارامترها به صورت همزمان در نظر گرفته خواهد شد.

در صورتی که بررسی به یک خطا روبرو شده باید خطای Pluf_Form_Invalid صادر شود.

Returns

array —

Cleaned data.

failed()

failed() 

Method just called after the validation if the validation failed.

This can be used to remove uploaded files. $this->['cleaned_data'] will be available but of course not fully populated and with possible garbage due to the error.

initial()

initial(  $name) : string

Get initial data for a given field.

Parameters

$name

Returns

string —

Initial data or '' of not defined.

render_top_errors()

render_top_errors() 

Get the top errors.

get_top_errors()

get_top_errors() 

Get the top errors.

field()

field(  $key) 

Get a given field by key.

Parameters

$key

current()

current() 

Iterator method to iterate over the fields.

Get the current item.

key()

key() 

next()

next() 

rewind()

rewind() 

valid()

valid() 

offsetUnset()

offsetUnset(  $index) 

Parameters

$index

offsetSet()

offsetSet(  $index,   $value) 

Parameters

$index
$value

offsetGet()

offsetGet(  $index) 

Parameters

$index

offsetExists()

offsetExists(  $index) 

Parameters

$index

save()

save(  $commit = true) : \User_Account

مدل داده‌ای را ذخیره می‌کند

مدل داده‌ای را بر اساس تغییرات تعیین شده توسط کاربر به روز می‌کند. در صورتی که پارامتر ورودی با نا درستی مقدار دهی شود تغییراد ذخیره نمی شود در غیر این صورت داده‌ها در پایگاه داده ذخیره می‌شود.

Parameters

$commit

داده‌ها ذخیره شود یا نه

Returns

\User_Account

مدل داده‌ای ایجاد شده

update()

update(  $commit = true) 

داده‌های کاربر را به روز می‌کند.

Parameters

$commit

Throws

\Pluf\Exception