コード例 #1
0
ファイル: Family.php プロジェクト: k-hasan-19/wiki
/**
 * 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;
}
コード例 #2
0
ファイル: FamilyController.php プロジェクト: Egishe/lifetree
 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));
 }
コード例 #3
0
 /**
  * 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!');
     }
 }