Example #1
0
 public function add()
 {
     try {
         $family = new \App\Model\FamilyTree();
         $name = Request::post('name');
         $parent_id = (int) Request::post('parent_id');
         if (empty($name)) {
             throw new \Exception('Empty name');
         }
         if (empty($parent_id)) {
             throw new \Exception('Empty parent id');
         }
         $params = ['name' => Html::escape($name), 'parent_id' => $parent_id, 'created_at' => time()];
         if (!$family->add($params)) {
             throw new \Exception('Error add family');
         }
         $notify['message'] = 'Add family success';
     } catch (\Exception $e) {
         $notify['error'] = $e->getMessage();
     }
     header("Content-type: application/json");
     $this->render('add', ['notify' => $notify]);
 }
Example #2
0
        ?>
        <tr>
            <td><?php 
        echo Html::escape($message['name']);
        ?>
</td>
            <td><?php 
        echo Html::escape($message['email']);
        ?>
</td>
            <td><?php 
        echo Html::escape($message['homepage']);
        ?>
</td>
            <td><?php 
        echo Html::escape($message['message']);
        ?>
</td>
            <td><?php 
        echo date('Y-m-d H:i:s', $message['created_at']);
        ?>
</td>
        </tr>
    <?php 
    }
    ?>

</table>
<?php 
} else {
    ?>
Example #3
0
    <div class="control-group">
        <label class="control-label" for="captcha">captcha (Сколько букв с слове "три")</label>
        <div class="controls">
            <input name="captcha" id="captcha" type="text" placeholder="captcha" required value="<?php 
echo Html::escape(Request::post('captcha'));
?>
">
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" for="message">Message</label>
        <div class="controls">
            <textarea name="message" required cols="40" id="message" placeholder="You Message" rows="10"><?php 
echo Html::escape(Request::post('message'));
?>
</textarea>
        </div>
    </div>

    <div class="form-actions">
        <button type="submit" class="btn btn-success">Submit Message</button>
        <button type="reset" class="btn">Cancel</button>
    </div>

    <?php 
if (!empty($notify['error'])) {
    ?>
        <div style="color: red"><?php 
    echo $notify['error'];