Добрый вечер. Подскажите пожалуйста:
При вводе в textarea с новой строки, записывалась в базу как новая запись.
Сама форма:
Сама форма html:
{*Блок добавления нового элемента*}
<div class="okay_list_body fn_new_coupon">
<div class="okay_list_body_item">
<div class="okay_list_row fix_row">
<div class="okay_list_heading okay_list_check"></div>
<div class="okay_list_boding okay_list_coupon_name fix_name">
<textarea class="form-control" name="new_code" type="text" value="" placeholder="{$btr->coupons_enter_name|escape}" style="height:200px;"/></textarea>
<input name="new_id" type="hidden" value=""/>
</div>
<div class="okay_list_boding okay_list_coupon_sale fix_sale">
<div class="input-group">
<input class="form-control" name="new_value" type="text" value="" placeholder="Введите значение"/>
<select class="selectpicker form-control" name="new_type">
<option value="percentage">%</option>
<option value="absolute">{$currency->sign}</option>
</select>
</div>
</div>
<div class="okay_list_boding okay_list_coupon_condit fix_condit">
<input class="form-control" type="text" name="new_min_order_price" value="" placeholder="{$btr->coupons_order_price|escape}">
</div>
<div class="okay_list_boding okay_list_coupon_validity fix_validity">
<div class="input-group">
<input class="form-control" type=text name="new_expire" value="">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
</div>
</div>
<div class="okay_list_boding okay_list_coupon_disposable fix_disposable">
<div class="fix_flex">
<div>Одноразовый?</div>
<div>
<input class="hidden_check" type="checkbox" name="new_single" id="single" value="1" />
<label class="okay_ckeckbox" for="single"></label>
</div>
</div>
</div>
<div class="okay_list_heading okay_list_coupon_count fix_count"></div>
<div class="okay_list_heading okay_list_close"></div>
</div>
</div>
</div>
Сама отправка:
/*Создание купона*/
if($this->request->post("new_code")){
$new_expire = $this->request->post('new_expire');
$new_coupon = new stdClass();
$new_coupon->id = $this->request->post('new_id', 'integer');
$new_coupon->code = $this->request->post('new_code', 'string');
if(!empty($new_expire)) {
$new_coupon->expire = date('Y-m-d', strtotime($new_expire));
} else {
$new_coupon->expire = null;
}
$new_coupon->value = $this->request->post('new_value', 'float');
$new_coupon->type = $this->request->post('new_type', 'string');
$new_coupon->min_order_price = $this->request->post('new_min_order_price', 'float');
$new_coupon->single = $this->request->post('new_single', 'float');
// Не допустить одинаковые URL разделов.
if(($a = $this->coupons->get_coupon((string)$new_coupon->code)) && $a->id != $new_coupon->id) {
$this->design->assign('message_error', 'code_exists');
} elseif(empty($new_coupon->code)) {
$this->design->assign('message_error', 'empty_code');
} else {
$new_coupon->id = $this->coupons->add_coupon($new_coupon);
$new_coupon = $this->coupons->get_coupon($new_coupon->id);
$this->design->assign('message_success', 'added');
}
}
Не могу вкурить как сделать, голову сломал...