@@ 59-68 (lines=10) @@ | ||
56 | * @param string $label |
|
57 | * @param array $fields |
|
58 | */ |
|
59 | public function __construct( $name, $label, $fields ) { |
|
60 | $this->set_name( $name ); |
|
61 | $this->set_label( $label ); |
|
62 | $this->add_fields( $fields ); |
|
63 | ||
64 | // Pick random ID |
|
65 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
66 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
67 | $this->group_id = 'carbon-group-' . $random_string; |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Add a group of fields. |
@@ 210-221 (lines=12) @@ | ||
207 | * @param string $name Field name |
|
208 | * @param string $label Field label |
|
209 | */ |
|
210 | protected function __construct( $name, $label ) { |
|
211 | $this->set_name( $name ); |
|
212 | $this->set_label( $label ); |
|
213 | $this->set_base_name( $name ); |
|
214 | ||
215 | // Pick random ID |
|
216 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
217 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
218 | $this->id = 'carbon-' . $random_string; |
|
219 | ||
220 | $this->init(); |
|
221 | } |
|
222 | ||
223 | /** |
|
224 | * Boot the field once the container is attached. |