Help us understand the problem. What is going on with this article?

Bootstrapでフォーム部品を横一行に表示したい

More than 5 years have passed since last update.

Bootstrapって、横幅全部使ってフォーム部品が表示される、みたいなのがデフォルトっぽくて、
日付とか時間とかね、入力欄は小さくていいから一行におさめたいって場合に結構悩んだのでメモ。
ちょっと、labelの使い方が間違ってるがまあとりあえずこんな感じで。

                <div class="form-inline">
                    <div class="form-group">
                        <label>日付</label>
                        <input name="jikan" id="datepicker" class="form-control" type="text">
                    </div>
                    <div class="form-group">
                        <label>時間</label>
                        <select name="hour" class="form-control">
                            <option>10</option>
                            <option>11</option>
                            <option>12</option>
                        </select> 
                        <label>:</label>
                    </div>
                    <div class="form-group">
                        <select name="min" class="form-control">
                            <option>57</option>
                            <option>58</option>
                            <option>59</option>
                        </select> 
                    </div>
                </div>

もしこれの時間セレクト部分をCakePHPのフォームヘルパーを使って表現したい、
ということだったら、以下のように書けばよい。

                    <div class="form-group">
<?php
                    echo $this->Form->input('jikan', array(
                        'type' => 'time',
                        'label' => '時間',
                        'timeFormat' => 24,
                        'selected' => '13:30:00',
                        'class' => 'form-control',
                        'interval' => 15
                    ));
?>
                    </div>

formのnameは自動的にhourがついてくれる

<select id="ModelJikanHour" class="form-control" name="data[Model][jikan][hour]">
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした