Beispiel #1
0
/**
 * Callback function to validate data
 * @return bool must return true or other hooks don't get called
 */
function validateFamily($editPage, $textBox1, $section, &$hookError)
{
    $ns = $editPage->mTitle->getNamespace();
    if ($ns == NS_FAMILY) {
        $family = new Family($editPage->mTitle->getText());
        $family->validate($textBox1, $section, $hookError, true);
    }
    return true;
}
Beispiel #2
0
 public function actionCreate()
 {
     $model = new Family();
     if (isset($_POST['Family'])) {
         $model->attributes = $_POST['Family'];
         $model->validate($model) && $model->save() && $this->redirect(Yii::app()->createUrl('family'));
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Update the specified resource in storage.
  * PUT /familylaws/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $validator = Family::validate(Input::only('name', 'description'));
     if ($validator->fails()) {
         return Redirect::to('/allfamilyLaws')->withErrors($validator)->withInput(Input::all());
     } else {
         $family = Family::find($id);
         $family->name = Input::get('name');
         $family->description = Input::get('description');
         $family->save();
         return Redirect::to('allfamilyLaws')->with('message', 'Family Law Practice Area was successfully updated!');
     }
 }