Made upload form use generic form field renderers

This commit is contained in:
Marcin Kurczewski 2014-08-09 21:46:02 +02:00
parent 1b99f17557
commit f93b6cf94b

View file

@ -111,57 +111,41 @@ $this->assets->addScript('../lib/tagit/jquery.tagit.js');
</div> </div>
</div> </div>
<div class="form-row safety"> <?php
<label>Safety:</label> $safety = PostSafety::getAll();
<div class="input-wrapper"> $context = new StdClass;
<?php $checked = false ?> $context->label = 'Safety';
<?php foreach (PostSafety::getAll() as $safety): ?> $context->name = 'safety';
<label> $context->optionValues = array_map(function($s) { return $s->toInteger(); }, $safety);
<input $context->optionLabels = array_map(function($s) { return ucfirst($s->toDisplayString()); }, $safety);
type="radio" $context->activeOptionValue = PostSafety::Safe;
name="safety" $this->renderExternal('input-radioboxes', $context);
<?php if (!$checked): ?>
checked="checked"
<?php endif ?>
value="<?= $safety->toInteger() ?>" />
<?= ucfirst($safety->toDisplayString()) ?> $context = new StdClass;
$context->label = 'Tags';
$context->name = 'tags';
$context->placeholder = 'Enter some tags&hellip;';
$this->renderExternal('input-text', $context);
<?php $checked = true ?> $context = new StdClass;
</label> $context->label = 'Source';
<?php endforeach ?> $context->name = 'source';
</div> $context->placeholder =' Where did you get this from? (optional)';
</div> $context->maxLength = Core::getConfig()->posts->maxSourceLength;
$this->renderExternal('input-text', $context);
<div class="form-row tags"> if (Core::getConfig()->uploads->allowAnonymousUploads)
<label>Tags:</label> {
<div class="input-wrapper"> $context = new StdClass;
<input type="text" name="tags" placeholder="enter some tags&hellip;"/> $context->label = 'Anonymity';
</div> $context->optionNames = ['anonymous'];
</div> $context->optionValuesDisabled = ['0'];
$context->optionValuesEnabled = ['1'];
<div class="form-row source"> $context->optionLabels = ['Don\'t show my name in this post'];
<label>Source:</label> $context->optionStates = [false];
<div class="input-wrapper"> $this->renderExternal('input-checkboxes', $context);
<input type="text" }
maxlength="<?= Core::getConfig()->posts->maxSourceLength ?>" ?>
name="source"
placeholder="where did you get this from? (optional)"/>
</div>
</div>
<?php if (Core::getConfig()->uploads->allowAnonymousUploads): ?>
<div class="form-row anonymous">
<label>Anonymity:</label>
<div class="input-wrapper">
<input type="hidden" name="anonymous" value="0"/>
<label>
<input type="checkbox" name="anonymous" value="1"/>
Don't show my name in this post
</label>
</div>
</div>
<?php endif ?>
</form> </form>
</div> </div>
</div> </div>